I’m currently testing an interface for Java which enables to use R calls with Java. Therefore I need a connection which also encapsulates a process.
Now I need to know, how JUnit processes those Unit Tests. I’m using JUnit4 with it’s @Before and @After annotations to init a new connection (internally it’s a process) once per test.
With “how JUnit processes” I mean:
- is every test executed in it’s own thread? ( which could probably cause problems)
- are those tests executed sequentially?
- do they have a specific order (not that important, but would be nice to know)
My concern is that those tests could cause problems which wouldn’t exist, if used properly (as documented) in a real environment.
The tests are executed sequentially. You should not rely on this fact, because that indicates you are not writing a pure unit test and have created an anti-pattern (in terms of testing). Each test must be its own separate piece of work with no external dependencies outside of
AfterandBeforeinitializations. I believe each test is executed in its own thread, once again this harkens back to your test suite not being pure unit tests.Unit tests only validate one small piece of a function, typically one possible logic branch. If you want to test the system integration you will need to do what is called integration testing. Further if you are looking to do multi-threaded testing I highly recommend: Multi-threaded TC