About line coverage

41 views
Skip to first unread message

Alberto Guerra González

unread,
Sep 4, 2021, 2:22:27 PM9/4/21
to PIT Users
Hi everyone!

I am very new to mutation testing so apologies for the noob questions.

I just ran my first experiment with PIT and I was a bit confused with the line coverage results.

Can anyone please explain why line coverage is 50% here? Coverage.png

My tests are the following:

@Test
public void factorialZero() {
assertEquals(1, App.factorial( 0 ));
}

@Test
public void factorialFive() {
assertEquals(5*4*3*2, App.factorial( 5 ));
}

Thanks!

Henry Coles

unread,
Sep 4, 2021, 3:12:49 PM9/4/21
to pitu...@googlegroups.com
Although it is not defined in the source, the java compiler generates an implicit no args constructor for the class. As the test does not instantiate the class, it is never called and therefore the line appears as uncovered.

--
You received this message because you are subscribed to the Google Groups "PIT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pitusers+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pitusers/e877618b-a3ce-42c5-96b6-542bf858a050n%40googlegroups.com.

Ullrich Hafner

unread,
Sep 4, 2021, 4:25:58 PM9/4/21
to pitu...@googlegroups.com
I don’t know the internal details about PIT but your class has a generated default constructor that is not covered in your tests since you are only using a static method. It would more make sense to use instance methods in your tests only.   

Am 04.09.2021 um 20:22 schrieb Alberto Guerra González <erca...@gmail.com>:

Hi everyone!

I am very new to mutation testing so apologies for the noob questions.

I just ran my first experiment with PIT and I was a bit confused with the line coverage results.

Can anyone please explain why line coverage is 50% here? <Coverage.png>

My tests are the following:

@Test
public void factorialZero() {
assertEquals(1, App.factorial( 0 ));
}

@Test
public void factorialFive() {
assertEquals(5*4*3*2, App.factorial( 5 ));
}

Thanks!

--
You received this message because you are subscribed to the Google Groups "PIT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pitusers+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pitusers/e877618b-a3ce-42c5-96b6-542bf858a050n%40googlegroups.com.
<Coverage.png>

Reply all
Reply to author
Forward
0 new messages