Open
Description
Description
When a test method is generated for "False" branch of a condition, the generated description is not obvious.
More readable - from the first glance - description would help the user to understand the test.
Context
- Set
useAssembleModelGenerator
to false inUtValueTestChecker
, - Add the following code as an integration test (use the same approach as in
ClassWithNullableFieldTest
), - Generate tests for the following code and check the generated test file.
class FirstClass {
SecondClass secondClass;
FirstClass(SecondClass second) {
this.secondClass = second;
}
}
class SecondClass {
FirstClass firstClass;
SecondClass(FirstClass first) {
this.firstClass = first;
}
}
public class ClassWithNullableField {
public FirstClass returnFirstClassWithNullableField(int value) {
if (value == 0) {
return new FirstClass(new SecondClass(null));
} else {
FirstClass first = new FirstClass(null);
first.secondClass = new SecondClass(first);
return first;
}
}
}
Expected behavior
A better solution need to be found.
Probably: add the parameter value to the description, like value = -255
Actual behavior
There are two test methods: value == 0 : False
and value == 0 : True
in Java doc and DisplayName annotation, while -255
is passed to the tested method as a parameter in first case.
Visual proofs
The following test class is generated:
/**
<pre>
Test executes conditions:
* {@code (value == 0): False }
* returns from: {@code return first; }
* </pre>
*/
@Test
@DisplayName("returnFirstClassWithNullableField: value == 0 : False -> return first")
public void testReturnFirstClassWithNullableField_ValueNotEqualsZero() throws Exception {
<...>
FirstClass actual = classWithNullableField.returnFirstClassWithNullableField(-255);
<...>
}
/**
<pre>
Test executes conditions:
* {@code (value == 0): True }
* returns from: {@code return new FirstClass(new SecondClass(null)); }
* </pre>
*/
@Test
@DisplayName("returnFirstClassWithNullableField: value == 0 : True -> return new FirstClass(new SecondClass(null))")
public void testReturnFirstClassWithNullableField_ValueEqualsZero() throws Exception {
<...>
FirstClass actual = classWithNullableField.returnFirstClassWithNullableField(0);
<...>
}
Environment
This bug doesn't show up in plugin (runIde
) environment.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Todo