I have a bunch of methods returning a HashSet. I would like my unit test to check the status of these objects. Confirm that someObject.getName() == "foobar".
However, the order of the hashset iterator is not guaranteed, so my unit tests fail several times. How to write block tests for something like this?
For instance:
@Test
public void testRowsToBeRead(){
HashSet<SomeObject> rows = new SomeObject().read();
assertEquals(19, rows.size());
for(SomeObject r:rows){
}
}
I think I could accept the answer too soon.
Now the problem is that I implemented the equals method, which only checks for 2 fields in the object for each project (it simulates a database table). However, in my unit test, I want to check all fields, such as description, etc., which do not match my peers. Therefore, if 2 fields are interchanged, and these fields do not coincide with the implementation, then unit test gives a false result.