lundi 8 mai 2017

how to verify application level exception is thrown and check its values

We just annotate the code to make sure that certain exception is thrown:

@Test(expected=RepositorySystemException.class)

This way, the test method will succeed as soon as this exception is thrown.

However I want to go one step further and try to check the values of the returned exception and the way I think is this-

try {
        repo.errorRepositoryMess();
    } catch (RepositorySystemException e) {
        Result<RepositoryFix> resultRepoFix= e.toResult();
        // play with Result values and do assertions on it
    }

However the above code doesn't have expected annotation and so I am thinking of another way to do the same thing.

Aucun commentaire:

Enregistrer un commentaire