AnsweredAssumed Answered

JUnit-Test with 50/50 chance to fail

Question asked by ronnybr on Feb 11, 2013
Latest reply on Feb 12, 2013 by ronald.van.kuijk
Hello developer community,

I started working on ACT-1555 ( and wrote a JUnit-test.
The code can be found here:
Unfortunately, the test only has a 50/50 chance to show the error (at least it seems 50/50 to me ;) ).
Weld's BeanManager implementation uses a set to keep its resolved beans. The test fails (and shows the bug) only when the first bean in the set is not the @Alternative annotated bean.
I am not really satisfied with a test, which doesn't show the possible bug with certainty.
Do you guys hava an idea, how to write the test in a better way?
I also looked for a way to manipulate the BeanManager but didn't find one.