poor coverage of method that uses Reflection.getCallerClass(int)
#2739
Labels
ctg-bug
Issue is a bug
Reflection.getCallerClass(int)
#2739
Description
UnitTestBot generates one test for a method that uses
Reflection.getCallerClass
. This one test does not fully explore the possible behaviors of the method under test. Generated comments claim that this test case succeeds, but it actually fails. TheReflection.getCallerClass
call might need to be mocked, but no such mock is used.To Reproduce
Steps to reproduce the behavior:
Check out revision jdeparser/jdeparser2@fd6310c. Important: use this specific revision, not the current
main
head revision.Verify that the checked-out code includes the following
org.jboss.jdeparser.Assertions.callerIs(Class<?>)
method:Add the following to
pom.xml
to explicitly select Java 1.8:Open this project in IntelliJ IDEA and link its
pom.xml
, thereby making this a Maven project.In the IntelliJ IDEA Project Settings, select a Java 1.8 SDK.
Use the UnitTestBot IntelliJ IDEA plugin to generate tests for the
org.jboss.jdeparser.Assertions.callerIs(Class<?>)
method. Leave all UnitTestBot settings at their defaults, other than selecting this one method to generate tests for.Expected behavior
UnitTestBot should have generated one or more tests that cover the various behaviors of the
callerIs
method, including passing tests that show various possible return values from this method. Specifically, I would have expected at least two test cases: one for atrue
result and one for afalse
result. Even better would have been three cases, to explore the two different paths that could lead to atrue
result.Comments associated with the generated tests should correctly reflect which will pass and which will fail.
Mocks should be used as needed, specifically for the
Reflection.getCallerClass(int)
call made by the method under test.Actual behavior
UnitTestBot generated a test class with a single test method:
Generated `AssertionsTest.java`
This test suite differs from each of the three expectations listed earlier:
With only a single call to
callerIs
, this suite does not fully explore the possible behaviors of the method under test.The one generated test case is documented as succeeding, but actually fails. The generated call to
callerIs
returnsfalse
, which then fails theassertTrue(actual)
check.No mock was created for the
Reflection.getCallerClass(int)
call made by the method under test.Environment
The text was updated successfully, but these errors were encountered: