integration-testing

Tests dependent on commonly used functionality with NUnit

时光毁灭记忆、已成空白 提交于 2019-12-05 11:18:16
I have some initialization code to use my API. The initialization may fail and I´d like to test it in an NUnit test. After the initialization the API may be used. I´m testing the API too, but all my test methods will use the same, common, initialization code. What I would ideally like is if this behavior: The Initialization test is run. The other tests are run if [1] succeeded. In all cases where [1] will fail, so will all other tests. But the valuable information is that [1] fails. That's where I most likely will find the problem. It would be nice if the other tests could be marked with ? or

Integration Testing with Flyway

非 Y 不嫁゛ 提交于 2019-12-05 08:57:46
I'm using Flyway to handle the database migration. Everything is working fine: the default location of the migration files is: main/resource/db/migration/V1... I am running integration tests and my setup uses an separate database schema for integration, which I would like to manage with flyway as well. The integration tests, though, are located in the test folder (not main ). When the Flyway bean executes migrate() , it doesn't find the migration files because they are in the main folder. If I put the migration files in test/resource/db/migration/V1... it works. I really don't want to have to

Cannot get @Rollback to work for my Spring JPA Integration Test

依然范特西╮ 提交于 2019-12-05 07:42:48
This here is a little test class that I have. Problem is that it is not rolling back the transaction after each test run. What have I done wrong? :) @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "/META-INF/catalog-spring.xml" }) @TransactionConfiguration(transactionManager = "transactionManager", defaultRollback = true) public class TermTest { @Autowired private CatalogService service; @Rollback(true) @Test public void testSimplePersist() { Term term = new Term(); term.setDescription("Description"); term.setName("BirdSubject8"); term.setIsEnabled("F"); term

Android test coverage report for multi module app

空扰寡人 提交于 2019-12-05 06:35:05
We have a multi module application. Where we have 3 library projects and 1 launch project. module1 (Libraray) module2 (Libraray) depends on module1 module3 (Libraray)depends on module1 Launch (Does not have any source code its just a launcher for all lib)depends on module1 and module 2. In module1 we are accessing module 2 and module 3 classes using facade pattern. Due to that we need to write all the test cases in Launch project as we have access the to all the classes in launch project so that we have access to all the classes and test cases will not fail due to NoClassDefException. When we

Grails integration tests and transactions

有些话、适合烂在心里 提交于 2019-12-05 06:30:04
I don't get why this integration test fails. I can get the test to pass by either removing the @Transactional(propagation = Propagation.REQUIRES_NEW) annotation above the service method, OR by setting transactional = false in the Integration Test I realize that the integration test itself is running in a transaction, and that's why I've got the annotation on the service method. class DbTests extends GrailsUnitTestCase { boolean transactional = true def customerService void testTransactionsCommit() { def orderIds = [1, 2, 3] orderIds.each { // lets make sure they all start out as Active def

How to create liquibase changeset for integration tests in springboot?

喜夏-厌秋 提交于 2019-12-05 06:18:11
I want mock data for integration tests by liquibase changeset, how to make that to not affect real database? I found partial idea from here , but I am using springboot and I hope there is simpler solution. Hi you can use liquibase's context parameter. For example create changeset which will have inserts loaded from sql file and specify the context for it. something like this: <changeSet id="test_data_inserts" author="me" context="test"> <sqlFile path="test_data.sql" relativeToChangelogFile="true" /> </changeSet> and in spring boot application.properties for test specify property liquibase

Invoke Dispose method on AutoFixture customization

只谈情不闲聊 提交于 2019-12-05 05:49:34
I'm using an AutoFixture customization to test a repository which access to a SQL Compact DB. Would be very helpful to me to delete this database as soon as the test is completed. Because the db is created in the customization constructor I think that the best place to delete it is in the dispose method. The code which I'm thinking is: internal class ProjectRepositoryCustomization : ICustomization { private readonly String _dbLocation; public ProjectRepositoryCustomization() { var tempDbLocation = Path.Combine(Path.GetTempPath(), "TempDbToDelete"); if (!Directory.Exists(tempDbLocation)) {

Accessing Spring beans in JerseyTest

♀尐吖头ヾ 提交于 2019-12-05 05:00:51
I'm trying to figure out how to access Spring beans from a subclass of JerseyTest. Extending JerseyTest I've managed to load the Spring context in my tests, but I haven't figured out how to access the spring context. My setup looks like this: public abstract class SpringJerseyTest extends JerseyTest { public SpringJerseyTest() throws Exception { super(new WebAppDescriptor.Builder("com.acme.resources") .contextPath("/") .contextParam("contextConfigLocation", "classpath:applicationContext.xml") .servletClass(SpringServlet.class) .contextListenerClass(ContextLoaderListener.class) .build()); } }

Spring Boot integration test responding with empty body - MockMvc

丶灬走出姿态 提交于 2019-12-05 04:43:54
I've seen similar questions to this, but I've yet to find a solution that works for me, so i'm posting it with hopefully enough details to resolve.. So I have the following class: @RunWith(SpringRunner.class) @SpringBootTest public class TestController { @Mock private Controller controller; private MockMvc mockMvc; @InjectMocks private SearchService service; @Before public void setUp(){ MockitoAnnotations.initMocks(this); this.mockMvc = MockMvcBuilders.standaloneSetup(controller).setControllerAdvice(new GlobalExceptionHandler()).build(); } @Test public void getSearchResults() throws Exception{

Robolectric, Problems with clicking list items

假装没事ソ 提交于 2019-12-05 03:59:21
I have been struggling with this problem a bit, and I think I am not getting something fundamental about Robolectric. Usually some google searches can help me get to the bottom of this type of problem, but between that and looking at the sample code I am not finding anything of use. I am trying to emulate a click on a list view item and check that an activity is launched after the click. I keep getting back that the current activity I am testing is the resulting activity. I tried removing all of the list item clicking code and checking the resulting activity, and this came back as the