Skip to content

Generated tests contain JUnit4 @Test and commented JUnit5 @DisplayName annotations #576

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
alisevych opened this issue Jul 22, 2022 · 1 comment · Fixed by #624
Closed
Assignees
Labels
comp-summaries Something related to the method names, code comments and display names generation ctg-bug Issue is a bug

Comments

@alisevych
Copy link
Member

Description

Tests generated with JUnit4 framework selected - contain JUnit4 @test and commented JUnit5 @DisplayName annotations.

To Reproduce

Steps to reproduce the behavior:

  1. IntelliJ IDEA with UTBot plugin installed is opened
  2. Open a project with JDK 8-11
  3. Open a public class with a public method
  4. Use plugin to generate tests with JUnit4 test framework selected

Expected behavior

Only JUnit4 annotations are supposed to be used.

Actual behavior

@org.junit.jupiter.api.DisplayName are present, though commented

Visual proofs (screenshots, logs, images)

import org.junit.Test;

import static org.junit.Assert.assertEquals;

public class BinarySearchTest {
...
    @Test
    //@org.junit.jupiter.api.DisplayName("rightBinSearch: array = long[10], key = 0L -> return 10")
    public void testRightBinSearchReturns10WithNonEmptyPrimitiveArrayAndCornerCase() {
...

Environment

Windows 10 Pro
IntelliJ IDEA 2022.1.3
UTBot plugin version: https://github.com/UnitTestBot/UTBotJava/actions/runs/2717703384

@korifey korifey moved this to Todo in UTBot Java Jul 22, 2022
@alisevych alisevych added ctg-bug Issue is a bug comp-summaries Something related to the method names, code comments and display names generation labels Jul 22, 2022
@alisevych
Copy link
Member Author

alisevych commented Jul 29, 2022

As discussed @onewhl @denis-fokin
The short description of the test method should be added as:

remove - for JUnit4 // Java doc has this information

@DisplayName("<short description>") - for JUnit5 - with corresponding import

@Test(description = "<short description>") - for TestNG

related docs: TestNG annotations, JUnit5 DisplayName, JUnit4 - no analogues.

onewhl added a commit that referenced this issue Aug 3, 2022
* Generate DisplayName annotation only for JUnit 5 #576

* Review fixes
Repository owner moved this from Todo to Done in UTBot Java Aug 3, 2022
tamarinvs19 pushed a commit that referenced this issue Aug 4, 2022
* Generate DisplayName annotation only for JUnit 5 #576

* Review fixes
denis-fokin pushed a commit that referenced this issue Aug 18, 2022
* Generate DisplayName annotation only for JUnit 5 #576

* Review fixes
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
comp-summaries Something related to the method names, code comments and display names generation ctg-bug Issue is a bug
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants