Failed PIT test with Java JUnit

76 views
Skip to first unread message

Zemeng Wang

unread,
Aug 27, 2021, 2:48:28 PM8/27/21
to PIT Users
Hi, I'm new to the PIT. Our report shows some failed test but I didn't understand.

I'm testing this log method:

return !StringUtils.equalsIgnoreCase(status.getStatus(), "SHIPPED")
&& !StringUtils.equalsIgnoreCase(status.getStatus(), "CANCELLED")
&& !StringUtils.equalsIgnoreCase(status.getStatus(), "CUSTOMER_PICKED_UP");
Has a failed:

negated conditional → SURVIVED

For each line.

And we have

eligibleStatuses.forEach(status -> logMessage.append(" , Qty = " + status.getQuantity() + " , Status = " + status.getStatus()));

Failed with:

removed call to java/util/stream/Stream::forEach → SURVIVED


How to solve these two issues?

Bangar Milind

unread,
Aug 29, 2021, 6:13:35 AM8/29/21
to PIT Users
This looks more of boolean return ... Based on number of conditions, you possibly require as many test cases which covers all the conditions , passing and exception included.

PIT will change the checked e.g the negated "!" will be updated as a positive condition and possibly thats where its complaining .

Thumb rule --> Cover all conditions

PS : If you have all the conditions covered , then try to run only the Mutator throwing the error and if using PIT plugin more that 1.6.x , check the test strength.

Hope this helps.
Reply all
Reply to author
Forward
0 new messages