Skip to content

feat: Support generate test methods in a test Java file#1173

Merged
jdneo merged 4 commits into
masterfrom
cs/generate-test
Apr 21, 2021
Merged

feat: Support generate test methods in a test Java file#1173
jdneo merged 4 commits into
masterfrom
cs/generate-test

Conversation

@jdneo

@jdneo jdneo commented Apr 13, 2021

Copy link
Copy Markdown
Member

Address the first part of #1172 -- Add test method and lifecycle methods from a test source

UI entry

Source Actions > Generate Tests...

Steps

  1. determine the test framework
    • check from the import statement
    • if no test related imports found, check classpath
  2. determine the methods to insert
    • Available options are:
      • Test
      • 4 lifecycle methods (setUp, tearDown, beforeClass, afterClass)
    • Existing lifecycle methods will be filtered out
  3. Create the workspace edit and apply

@jdneo jdneo added this to the 0.28.2 milestone Apr 13, 2021
Comment thread src/codeActionProvider.ts Outdated
Comment thread src/commands/generationCommands.ts Outdated
Comment on lines +205 to +208
final List<String> frameworkList = availableFrameworks.stream()
.sorted((kind1, kind2) -> kind1.getValueForRank() - kind2.getValueForRank())
.map(framework -> framework.toString())
.collect(Collectors.toList());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to reorder the available frameworks since you already preset the priority when you parse test framework from file or project.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since availableFrameworks is set, so I think we still need sort it?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When you find available frameworks, you already follow the order [junit5, junit4, testng] to search them. This is already the expected order you want.

Comment thread src/codeActionProvider.ts Outdated
@jdneo jdneo merged commit 1652e46 into master Apr 21, 2021
@jdneo jdneo deleted the cs/generate-test branch April 21, 2021 04:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants