I am beginner on Java and I have a little problem with UnitTests with Java.
I think my problem we will be simple for you.
I put here my code and my error. On internet I found this is a problem with hashcode. I need to recreate them but I don't know why and how.. ^^
My method :
public void setGroupModel(GroupModel groupModel) {
this.groupModel = groupModel;
this.groupModel.add(this);
}
My UnitTest :
public class CellControllerTest {
protected CellController cellController;
@Before
public void setUp() throws Exception {
cellController = new CellController();
}
@After
public void tearDown() throws Exception{
}
@Test
public void testClick() throws Exception{
GroupModel groupModel = new GroupModel();
CellModel cellModel = new CellModel()
cellController.click(cellModel);
assertEquals(groupModel, cellModel.getGroupModel());
}
}
My error
java.lang.AssertionError: expected:<model.GroupModel@6d5380c2> but was:<model.GroupModel@45ff54e6>
I think the problem is : this.groupModel = groupModel;
Please can you help me and tell me what I have to write and why? :)
Thx very much !
Aucun commentaire:
Enregistrer un commentaire