If you ask about the assignment operator &= , it only stores the true variable if the right-hand side of the argument is also true (if it was already false, it will remain false). It works just like += , and a &= b matches a = a & b , the & operator is a Boolean union (AND).
pass &= test(cnt == 5, test++);
is short for
if( ! test( cnt == 5, test ) ) pass = false; test++;
I assume that it is part of the unit testing code and claims that cnt == 5 also counts the number of tests and the total result (pass or fail).
Using Junit, you donโt have to manually track the number of tests or the end result, and you could write
assertEquals("count is correct", 5, cnt);
It will also provide a useful conclusion, which will help to find out what exactly failed (for example, the value of an incorrect calculation).
source share