unit test

This is a consistent behavior - a class contains several unit tests - each test inserts a few documents, then performs some manipulation on those documents. The class is declared thus:

@Features({PlatformFeature.class, TransientStoreFeature.class})
@RepositoryConfig(init=DefaultRepositoryInit.class, cleanup=Granularity.METHOD)
@Deploy({ ... })
public class TestCaseX {
    CoreSession session;

The behavior is: when running the entire class, one particular test case - say test case #3 of 5 - will fail because a line of code session.getDocument returns a null even though right above it the document was added to the repository. The test case fails from the command line using Maven, and within IntelliJ. If - in IntelliJ - I do nothing different other than put a break point on the test case statement that is returning a null - then let the test case proceed - the test succeeds. It seems like a timing issue related to how the repository is cleaned up between test cases. I have some of these working with @RandomBug.Repeat annotations. But in other cases - even this does not overcome the issue. Wondering if others have experienced this and there is a well-known practice to resolve… Thanks

0 votes

0 answers



Right above it in the same test method??? Document creation should be deterministic…