tests in SUCCESSFUL EXECUTIONS
region fail during class initialization
#2741
Labels
ctg-bug
Issue is a bug
Description
UnitTestBot generates four tests for a method. All four tests are documents as successful, but three of the four tests actually fail during initialization of the class that contains the method under test.
To Reproduce
Steps to reproduce the behavior:
Check out https://github.com/suqun/JavaSecurity. For the issue reported here, the current
master
head revision of this repository was suqun/JavaSecurity@89d6203, but it is not clear whether this issue is sensitive to this specific revision.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
com.larry.security.signature.dsa.DSA.jdkDSA()
method. Leave all UnitTestBot settings at their defaults, other than selecting this one method to generate tests for.Expected behavior
The
jdkDSA
method under test clearly was not designed with testing in mind. It takes no arguments and returns no value, so extensive mocking would be needed in order to test this method at all. Without mocks and/or output capture, the best we could hope for is a test that verifies that the method returns when called, without throwing an exception.That being said, we expect that comments associated with the generated tests should correctly reflect which will pass and which will fail.
Actual behavior
UnitTestBot generated a test class with four test methods:
Generated `DSATest.java`
The last, fuzzer-generated test is simply a direct call to the method under test. This test passes, and is all one could expect without mocking.
The first three tests, though, all fail with
NullPointerException
s when run. This result disagrees with the expectations set by the generated comments, all of which predict that the tests will pass. For example, all three of these failing tests are enclosed in a region bounded by:These uncaught
NullPointerException
s may seem surprising, since the entire body of the method under test is enclosed within atry
block that catches anyException
. However, careful examination of the following stack traces reveals that theNullPointerException
s arise immediately before eachDSATest
test method callsDSA.jdkDSA()
. The problem seems to be triggered when loading and initializing theDSA
class.Failing stack trace when running `testJdkDSA_CatchException`
Failing stack trace when running `testJdkDSA_CatchException_1`
Failing stack trace when running `testJdkDSA_CatchException_2`
Environment
The text was updated successfully, but these errors were encountered: