Skip to content

refactor: Leverage test finder for test discovery#1131

Merged
jdneo merged 2 commits into
masterfrom
cs/refactor-test-searcher
Jan 27, 2021
Merged

refactor: Leverage test finder for test discovery#1131
jdneo merged 2 commits into
masterfrom
cs/refactor-test-searcher

Conversation

@jdneo

@jdneo jdneo commented Jan 26, 2021

Copy link
Copy Markdown
Member

This PR leverage the upstream Test Finder for test discovery.

The previous implementation used SearchEngine, since it's not good at handleing meta annotation, some bugs are introduced.

fix #641
fix #773
fix #818

@jdneo jdneo added the bug label Jan 26, 2021
@jdneo jdneo added this to the 0.28.0 milestone Jan 26, 2021
@jdneo jdneo added the eng Debts for engineering label Jan 26, 2021
final IJavaSearchScope scope = createSearchScope(params);
if (params.getLevel() == TestLevel.METHOD) {
// unreachable code since the client will directly run the test when it's triggered from method level
return Collections.emptyList();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

if it's unreachable, maybe throw excepetion or do assertion? (when unexpected scenario does occur, it would be fast located..)

for (final IType type : types) {
final TestItem item = TestItemUtils.constructTestItem(type, TestLevel.CLASS, TestKind.JUnit5);
item.setChildren(Arrays.stream(type.getMethods())
.map(m -> String.format("%s@%s", m.getJavaProject().getProject().getName(),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

String.format("%s@%s" is much slower. Because the pattern is simple, suggest to use string + "@" + string, which will be optimized by JVM to use StringBuilder under the hood.

for (final IType type : types) {
final TestItem item = TestItemUtils.constructTestItem(type, TestLevel.CLASS, TestKind.JUnit);
item.setChildren(Arrays.stream(type.getMethods())
.map(m -> String.format("%s@%s", m.getJavaProject().getProject().getName(),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

String.format is slower

Signed-off-by: Sheng Chen <sheche@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug eng Debts for engineering

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for method detection with @Testable (and meta) Cannot run meta annotation tests from test explorer The test cases will run multiple times.

2 participants