Scenario: I have some integration tests. One of them tests a delete. So I've done:
@Test
@Order(6)
public void delete() {
rfxCriteriRepository.delete(rfxCriteriEconomico.getIdrfxcriteri());
}
to simply test if the method throws no exception. Than, to be sure that the delete is successfull, I've added:
@Test
@Order(7)
public void getDelete() {
RfxCriteri rfxCriteriEconomicoDb = rfxCriteriRepository.findByIdrfxcriteri(
rfxCriteriEconomico.getIdrfxcriteri()
);
Assertions.assertNull(rfxCriteriEconomicoDb);
}
My idea is that the first test tests the code. If the code is well written, it should throw no exception, and the test pass. The second test tests that the delete effectively deleted the entry from the database. IMHO they are two separate tests.
Do you think every test must have an assert? Or do you think these two tests should be an unique test? Can someone point me to some guide about unit testing that says something about it?
Aucun commentaire:
Enregistrer un commentaire