mojohaus / cobertura-maven-plugin

Cobertura Maven Plugin
https://www.mojohaus.org/cobertura-maven-plugin/
25 stars 20 forks source link

Cobertura does not include results in test-coverage #34

Open nito90 opened 7 years ago

nito90 commented 7 years ago

Hi to all, I use maven plugin Cobertura 2.7. I want to test the below method.

protected void validateCategoryAndAssociatedQuestionType(CategoryQuestionDto dto, Category cat, Question que) {

if (!((cat instanceof TriviaCategory && que instanceof TriviaQuestion) || (cat instanceof TestCategory && que instanceof TestQuestion) || (cat instanceof GuessingGameCategory && que instanceof GuessingGameQuestion))) 
{

throw new QuestionAndCategoryNotOfTheSameTypeException("Question with id: " + dto.getId().getQuestionId() + " and Category with id: " + dto.getId().getCategoryId() + " are not of the same type");

}
}

and I am testing this with the below test.

@Test(expected = QuestionAndCategoryNotOfTheSameTypeException.class)

public void validateCategoryAndAssociatedQuestionTypeFailure6(){

                GuessingGameCategory category = new GuessingGameCategory();
        TestQuestion question = new TestQuestion();

                question.setId(1);
            category.setId(1);

        CategoryQuestion pair = new CategoryQuestion(category, question, (short)1);
        service.validateCategoryAndAssociatedQuestionType(new  CategoryQuestionDto().fromEntity(pair), category, question);
    }

Can someone tell me why this method in coverage report is with red lines?