What is the difference between Unit, Integration, Regression and Acceptance Testing?

Briefly: Unit testing – You unit test each individual piece of code. Think each file or class. Integration testing – When putting several units together that interact you need to conduct Integration testing to make sure that integrating these units together has not introduced any errors. Regression testing – after integrating (and maybe fixing) you … Read more

Mock external server during integration testing with Spring

After playing a bit with various scenarios, here is the one way how can one achieve what was asked with minimal interventions to the main code Refactor your controller to use a parameter for thirdparty server address: @RestController public class HelloController { @Value(“${api_host}”) private String apiHost; @RequestMapping(“/hello_to_facebook”) public String hello_to_facebook() { // Ask facebook about … Read more

How should I set up my integration tests to use a test database with Entity Framework?

Thanks so much to @Justin and @Petro for your answers, which have helped me immensely. The solution I have come up with is a combination of the techniques you suggested. The solution described below provides a new database for each run of the tests, and a separate transaction for each test. I added a connection … Read more

Reconfigure dependencies when Integration testing ASP.NET Core Web API and EF Core

@ilya-chumakov’s answer is awesome. I just would like to add one more option 3. Use ConfigureTestServices method from WebHostBuilderExtensions. The method ConfigureTestServices is available in the Microsoft.AspNetCore.TestHost version 2.1(on 20.05.2018 it is RC1-final). And it lets us override existing registrations with mocks. The code: _server = new TestServer(new WebHostBuilder() .UseStartup<Startup>() .ConfigureTestServices(services => { services.AddTransient<IFooService, MockService>(); … Read more

Is there a way to execute a teardown function after all tests have been run?

Here is an example implementation of the custom test framework solution mentioned by Masklinn: #![feature(custom_test_frameworks)] #![feature(test)] #![test_runner(custom_test_runner)] extern crate test; use test::{test_main_static, TestDescAndFn}; fn main() {} pub fn custom_test_runner(tests: &[&TestDescAndFn]) { println!(“Setup”); test_main_static(tests); println!(“Teardown”); } #[cfg(test)] mod tests { #[test] fn test1() { println!(“Test 1”) } #[test] fn test2() { println!(“Test 2”) } } This … Read more

Mock IOptionsMonitor

You are calling the constructor of the OptionsMonitor<TOptions> class incorrectly. In this case I would have just mocked the IOptionsMonitor<AuthenticationSettings> interface For example using Moq AuthenticationSettings au = new AuthenticationSettings() { … }; var monitor = Mock.Of<IOptionsMonitor<AuthenticationSettings>>(_ => _.CurrentValue == au); ActiveDirectoryLogic _SUT = new ActiveDirectoryLogic(monitor);

How to run a single specific test case when using protractor

Jasmine added fit and fdescribe in 2.1 for running single tests or describe blocks. http://pivotallabs.com/new-key-features-jasmine-2-1/ This feature almost made it in the 2.0 release. Now enough of this functionality is present to support fit and fdescribe for focused spec and suite running. from 2.1 git lib/jasmine-core/jasmine.js var jasmineInterface = { describe: function(description, specDefinitions) { return … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)