integration-testing

Why component scanning does not work for Spring Boot unit tests?

此生再无相见时 提交于 2019-12-01 09:29:45
The service class FooServiceImpl is annotated with @Service aka @Component which makes it eligible for autowiring. Why this class is not being picked up and autowired during unit tests? @Service public class FooServiceImpl implements FooService { @Override public String reverse(String bar) { return new StringBuilder(bar).reverse().toString(); } } @RunWith(SpringRunner.class) //@SpringBootTest public class FooServiceTest { @Autowired private FooService fooService; @Test public void reverseStringShouldReverseAnyString() { String reverse = fooService.reverse("hello"); assertThat(reverse)

Why component scanning does not work for Spring Boot unit tests?

瘦欲@ 提交于 2019-12-01 06:57:33
问题 The service class FooServiceImpl is annotated with @Service aka @Component which makes it eligible for autowiring. Why this class is not being picked up and autowired during unit tests? @Service public class FooServiceImpl implements FooService { @Override public String reverse(String bar) { return new StringBuilder(bar).reverse().toString(); } } @RunWith(SpringRunner.class) //@SpringBootTest public class FooServiceTest { @Autowired private FooService fooService; @Test public void

Grails 2.0 integration test pollution?

醉酒当歌 提交于 2019-12-01 06:51:36
So i have a small integration test that houses 5 tests in total. Running that test exclusively results in all tests passed. However running my entire test suite results in 4 test failures of the 5. I've just recently upgraded to grails-2.0 from 1.3.7 and i switched from hsqldb to h2. Has anyone any pointers in which direction i should be looking in order to fix this (test-pollution) problem? Domain model Integration test: class SeriesIntegrationTests extends GrailsUnitTestCase { Series series Episode episode protected void setUp() { super.setUp() series = new Series(ttdbId: 2348); episode =

Integration tests with spring-security and ldap

僤鯓⒐⒋嵵緔 提交于 2019-12-01 06:31:31
Spring embedded ldap server in unit tests is similar, however no answer was given that suites me. I can run my integration tests with spring and the embedded ldap server of spring-security without any problems. However, I haven't find a way yet to clear the embedded ldap server and load the ldif again to provide a common test environment. LdapTestUtils of spring-ldap provides a cleanAndSetup() method. However, this does not work with the suggested version (1.5.5) of apache-ds, as LdifFileLoader now requires a CoreSession instead of the DirContext provided by LdapTestUtils. This causes a java

How do I control spring injections that vary between the test environment and the production environment?

为君一笑 提交于 2019-12-01 06:20:21
I'm setting up a CI situation in which I will deploy my web app to a test environment. In this test environment, I want the business objects used by the app to be mocks of the real ones; the mocks will return static test data. I'm using this to run tests agains my ui. I'm controlling the injections of these business object dependencies with Spring; it's a struts 2 application, for what that's worth. My question is Maven related, I think. What is the best way to have my Maven build determine whether or not to build the spring configuration out for injecting the mocks or injecting the real thing

How to reuse test code in imported package? [duplicate]

风流意气都作罢 提交于 2019-12-01 06:07:40
This question already has an answer here: Can I create shared test utilities in go? 1 answer Here is my directory hierarchy: / |-- main.go // package main, an HTTP server which accepts request and calls C/U APIs in pkg1 to finish certain task |-- main_test.go // wants to call veryfyTaskNumber in pkg1_test |-- pkg1 // package pkg1, CRUD APIs with Retrieve&Delete unexported for safety |-- pkg1_test.go // contains a function verifyTaskNumber(*testing.T, taskName string, expectedNo int) which calls internal Retrieve function in pkg1 I have some utility functions for tests only in pkg1_test.go .

ASP.Net Core Integration Testing

冷暖自知 提交于 2019-12-01 05:36:39
I'm struggling to get any sort of integration tests working with ASP.Net Core RC2. I have created a basic web project which runs fine in the browser showing the default page as expected. I then added a new class (in the same project) with the following test code: [TestClass] public class HomeControllerTests { private HttpClient client; [TestInitialize] public void Initialize() { // Arrange var host = new WebHostBuilder() .UseEnvironment("Development") .UseKestrel() .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() .UseStartup<Startup>(); TestServer server = new TestServer

How to test the SSIS Packages?

南楼画角 提交于 2019-12-01 05:18:31
问题 How to test the SSIS Packages ? what are the things should be taken care while testing the ssis packages? what are the testcase steps should be written while testing ? 回答1: ssisUnit is a great tool for unit testing an SSIS package. The only caveat I have run into is that you need to run the unit tests on a machine with SSIS server components installed. I work in a shop where I have the SSIS client components installed, but the server is remote (I have Sql Server Express on my local box) so I

How do I control spring injections that vary between the test environment and the production environment?

↘锁芯ラ 提交于 2019-12-01 05:08:43
问题 I'm setting up a CI situation in which I will deploy my web app to a test environment. In this test environment, I want the business objects used by the app to be mocks of the real ones; the mocks will return static test data. I'm using this to run tests agains my ui. I'm controlling the injections of these business object dependencies with Spring; it's a struts 2 application, for what that's worth. My question is Maven related, I think. What is the best way to have my Maven build determine

NUnit integration tests and dependency injection

最后都变了- 提交于 2019-12-01 04:39:28
I'm currently making use of Castle Windsor version 2.1 as my container and would like to perform integration tests using the services registered with it. Currently, I do this my using the Common Service Locator to retrieve my service instance and perform my integration tests against it as such: var myService = ServiceLocator.Current.GetInstance<IMyService>(); // do stuff with myService What I'd ideally like to do is have my service dependencies injected into my NUnit test fixture automatically. Spring seems to offer this functionality , but I can't locate anything similar using Castle. Can