Skip to content

Commit 69b527e

Browse files
author
Hélios GILLES
committed
Fix test
1 parent 6bc89e9 commit 69b527e

2 files changed

Lines changed: 13 additions & 4 deletions

File tree

org.moreunit.plugin/src/org/moreunit/elements/TestmethodCreator.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import static java.util.Collections.addAll;
44

55
import java.util.ArrayList;
6+
import java.util.Arrays;
67
import java.util.List;
78
import java.util.ListIterator;
89

@@ -419,9 +420,18 @@ private IMethod createMethod(String methodName, String methodString, IMethod sib
419420
{
420421
if(doesMethodExist(methodName))
421422
return null;
422-
423423
try
424424
{
425+
String testImport = TestTypeConstants.TEST_ANNOTATION.get(testType);
426+
if(testImport != null && Arrays.stream(testCaseCompilationUnit.getImports()).noneMatch(i -> i.getElementName().equals(testImport)))
427+
{
428+
testCaseCompilationUnit.createImport(testImport, null, null);
429+
}
430+
String staticImportBaseClass = TestTypeConstants.STATIC_IMPORT_BASE_CLASS.get(testType);
431+
if(staticImportBaseClass != null && Arrays.stream(testCaseCompilationUnit.getImports()).noneMatch(i -> i.getElementName().equals(staticImportBaseClass)))
432+
{
433+
testCaseCompilationUnit.createImport(staticImportBaseClass, null, null);
434+
}
425435
return testCaseCompilationUnit.findPrimaryType().createMethod(format(methodString), sibling, true, null);
426436
}
427437
catch (JavaModelException e)

org.moreunit.swtbot.test/src/org/moreunit/create/ClassCreationTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,10 @@ public void should_create_test_with_default_package_for_junit5() throws JavaMode
4848
public boolean test() throws Exception
4949
{
5050
try {
51-
context.getCompilationUnit("testing.TheWorldTest");
51+
return context.getCompilationUnit("testing.TheWorldTest").findPrimaryType().getMethods().length > 0;
5252
} catch (IllegalArgumentException ex) {
53-
return false;
5453
}
55-
return true;
54+
return false;
5655
}
5756

5857
@Override

0 commit comments

Comments
 (0)