Well, I'm lucky to use org.unbroken-dome.gradle-plugins:gradle-testsets-plugin:1.4.2 in my project, but I'm a little confused with the integration test execution sequence.
I know it is not a good practice to make integration test effect each other, but all my integration tests are creating data in one memory database currently. And sometimes the integration tests pass without any problems, but sometimes they just stuck in trouble. I'm sure the different execution sequences do the job lead test result to mysterious. So what's the answer to the question I'm wondering and how can i configure it? Any clues related to the topic will be highly appreciated.
Hi,
it's always a good practice to make your individual test cases as isolated as possible -- regardless of the test framework or build tools you are using.
if you're using a transactional DB, you can have each test use its own transaction that will be rolled back after the test (so that the other tests won't even see that data). For example, Spring offers some support for these kinds of tests.
You can have each test create its own table/collection with its own unique name (e.g. using a UUID suffix)
Some DBMS allow you to have separate schemas within the same database server
Or you could even create a separate DB server instance for each test (for in-memory databases or even with Docker containers this should still be acceptably fast)
If none of these work, you should configure your test framework so that tests that might interfere with each other are never executed in parallel, and make sure that each test cleans up after itself - even if it fails.
Well, I'm lucky to use org.unbroken-dome.gradle-plugins:gradle-testsets-plugin:1.4.2 in my project, but I'm a little confused with the integration test execution sequence. I know it is not a good practice to make integration test effect each other, but all my integration tests are creating data in one memory database currently. And sometimes the integration tests pass without any problems, but sometimes they just stuck in trouble. I'm sure the different execution sequences do the job lead test result to mysterious. So what's the answer to the question I'm wondering and how can i configure it? Any clues related to the topic will be highly appreciated.