-
Notifications
You must be signed in to change notification settings - Fork 45
Open
Labels
comp-codegenIssue is related to code generatorIssue is related to code generatorctg-bugIssue is a bugIssue is a bug
Description
Description
Consider a case when we have a custom class named like a standard exception. It cause compilation error when we try to generate test code for it.
To Reproduce
Consider the following class:
public class ClassNotFoundException {
public Class<?> getClass(String className) throws java.lang.ClassNotFoundException {
return Class.forName(className);
}
}
The generated test looks like as follows:
@Test
@DisplayName("getClass: className = blank string -> throw ClassNotFoundException")
public void testGetClassThrowsCNFEWithBlankString() throws ClassNotFoundException {
ClassNotFoundException classNotFoundException = new ClassNotFoundException();
assertThrows(ClassNotFoundException.class, () -> classNotFoundException.getClass(" "));
}
This code does not compile because the declaration of the test method must be replaced with the following:
public void testGetClassThrowsCNFEWithBlankString() throws java.lang.ClassNotFoundException
And the last line must be replaces with:
assertThrows(java.lang.ClassNotFoundException.class, () -> classNotFoundException.getClass(" "));
Metadata
Metadata
Assignees
Labels
comp-codegenIssue is related to code generatorIssue is related to code generatorctg-bugIssue is a bugIssue is a bug
Type
Projects
Status
Todo