Integration testing ASP.NET Core with .NET Framework – can’t find deps.json

We should get “Program” class from the main project but it automatically references Microsoft.AspNetCore.Mvc.Testing.Program class public class VersioningTests : IClassFixture<WebApplicationFactory<Program>> this code must reference our main Program code. So we must put a reference to the Program class on the last line in Program.cs file: public partial class Program { }

How to use WebApplicationFactory in .net6 (without speakable entry point)

Note that if you are trying to use xUnit and its IClassFixture<T> pattern, you will run into problems if you just use the InternalsVisibleTo approach. Specifically, you’ll get something like this: “Inconsistent accessibility: base class WebApplicationFactory<Program> is less accessible than class CustomWebApplicationFactory.” Of course you can solve this by making CustomWebApplicationFactory internal but it only …

Read more

How to mock request and response in nodejs to test middleware/controllers?

There’s a semi decent implementation at node-mocks-http Require it: var mocks = require(‘node-mocks-http’); you can then compose req and response objects: req = mocks.createRequest(); res = mocks.createResponse(); You can then test your controller directly: var demoController = require(‘demoController’); demoController.login(req, res); assert.equal(res.json, {}) caveat There is at time of writing an issue in this implementation to …

Read more

Login with code when using LiveServerTestCase with Django

You can’t login user from selenium driver. It’s just impossible without some hacks. But you can login once per TestCase by moving it to setUp method. You can also avoid copy-pasting by creating your class inherit from LiveServerTestCase. UPDATE This code worked for me: self.client.login(username=superuser.username, password=’superpassword’) #Native django test client cookie = self.client.cookies[‘sessionid’] self.browser.get(self.live_server_url + …

Read more

Maven separate Unit Test and Integration Tests

The solution is this: <build> <pluginManagement> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.19.1</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-failsafe-plugin</artifactId> <version>2.19.1</version> </plugin> </plugins> </pluginManagement> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.6.1</version> <configuration> <source>1.7</source> <target>1.7</target> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-failsafe-plugin</artifactId> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <skip>${surefire.skip}</skip> </configuration> <executions> <execution> <goals> <goal>integration-test</goal> <goal>verify</goal> </goals> </execution> </executions> </plugin> </plugins> </build> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.12</version> …

Read more