Skip to content

Commit

Permalink
update target and switch on all cleanup parts in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
carstenartur committed Nov 17, 2024
1 parent f7b69a9 commit 8ddac4c
Show file tree
Hide file tree
Showing 8 changed files with 325 additions and 797 deletions.
5 changes: 4 additions & 1 deletion sandbox_junit_cleanup/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.jface,
org.eclipse.ui.workbench,
org.eclipse.jdt.core.manipulation,
sandbox_common
sandbox_common,
org.junit,
org.eclipse.jdt.junit.runtime,
org.eclipse.jdt.junit4.runtime
Bundle-ActivationPolicy: lazy
Eclipse-RegisterBuddy: org.eclipse.jdt.core.manipulation
Import-Package: org.sandbox.jdt.internal.common,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,32 @@
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.junit.JUnitCore;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.EnumSource;
import org.sandbox.jdt.internal.corext.fix2.MYCleanUpConstants;
import org.sandbox.jdt.ui.tests.quickfix.rules.AbstractEclipseJava;
import org.sandbox.jdt.ui.tests.quickfix.rules.EclipseJava8;
import org.sandbox.jdt.ui.tests.quickfix.rules.EclipseJava17;


public class JUnitMigrationCleanUpTest {

@RegisterExtension
AbstractEclipseJava context4junit4= new EclipseJava8();
AbstractEclipseJava context4junit4= new EclipseJava17();

@RegisterExtension
AbstractEclipseJava context4junit5= new EclipseJava8();
AbstractEclipseJava context4junit5= new EclipseJava17();

IPackageFragmentRoot fRootJUnit4;
IPackageFragmentRoot fRootJUnit5;

@BeforeEach
public void setup() throws CoreException {
fRootJUnit4= context4junit4.createClasspathForJUnit("4");
fRootJUnit5= context4junit5.createClasspathForJUnit("5");
fRootJUnit4= context4junit4.createClasspathForJUnit(JUnitCore.JUNIT4_CONTAINER_PATH);
fRootJUnit5= context4junit5.createClasspathForJUnit(JUnitCore.JUNIT5_CONTAINER_PATH);
}

enum JUnitCleanupCases{
Expand Down Expand Up @@ -801,8 +802,21 @@ public void test3() throws IOException{
@EnumSource(JUnitCleanupCases.class)
public void testJUnitCleanupParametrized(JUnitCleanupCases test) throws CoreException {

Check notice

Code scanning / Pmd (reported by Codacy)

JUnit tests should include assert() or fail() Note test

JUnit tests should include assert() or fail()
IPackageFragment pack= fRootJUnit4.createPackageFragment("test", true, null);
ICompilationUnit cu= pack.createCompilationUnit("MyTest.java", test.given, false, null); //$NON-NLS-1$
ICompilationUnit cu= pack.createCompilationUnit("MyTest.java", test.given, true, null); //$NON-NLS-1$
context4junit4.enable(MYCleanUpConstants.JUNIT_CLEANUP);
context4junit4.enable(MYCleanUpConstants.JUNIT_CLEANUP_4_ASSERT);
context4junit4.enable(MYCleanUpConstants.JUNIT_CLEANUP_4_ASSUME);
context4junit4.enable(MYCleanUpConstants.JUNIT_CLEANUP_4_SUITE);
context4junit4.enable(MYCleanUpConstants.JUNIT_CLEANUP_4_BEFORE);
context4junit4.enable(MYCleanUpConstants.JUNIT_CLEANUP_4_AFTER);
context4junit4.enable(MYCleanUpConstants.JUNIT_CLEANUP_4_BEFORECLASS);
context4junit4.enable(MYCleanUpConstants.JUNIT_CLEANUP_4_AFTERCLASS);
context4junit4.enable(MYCleanUpConstants.JUNIT_CLEANUP_4_IGNORE);
context4junit4.enable(MYCleanUpConstants.JUNIT_CLEANUP_4_TEST);
context4junit4.enable(MYCleanUpConstants.JUNIT_CLEANUP_4_RULETEMPORARYFOLDER);
context4junit4.enable(MYCleanUpConstants.JUNIT_CLEANUP_4_RULETESTNAME);
context4junit4.enable(MYCleanUpConstants.JUNIT_CLEANUP_4_EXTERNALRESOURCE);
context4junit4.enable(MYCleanUpConstants.JUNIT_CLEANUP_4_RUNWITH);
context4junit4.assertRefactoringResultAsExpected(new ICompilationUnit[] {cu}, new String[] {test.expected}, null);
}

Expand Down Expand Up @@ -902,6 +916,19 @@ public start(){
}
""", false, null); //$NON-NLS-1$
context4junit4.enable(MYCleanUpConstants.JUNIT_CLEANUP);
context4junit4.enable(MYCleanUpConstants.JUNIT_CLEANUP_4_ASSERT);
context4junit4.enable(MYCleanUpConstants.JUNIT_CLEANUP_4_ASSUME);
context4junit4.enable(MYCleanUpConstants.JUNIT_CLEANUP_4_SUITE);
context4junit4.enable(MYCleanUpConstants.JUNIT_CLEANUP_4_BEFORE);
context4junit4.enable(MYCleanUpConstants.JUNIT_CLEANUP_4_AFTER);
context4junit4.enable(MYCleanUpConstants.JUNIT_CLEANUP_4_BEFORECLASS);
context4junit4.enable(MYCleanUpConstants.JUNIT_CLEANUP_4_AFTERCLASS);
context4junit4.enable(MYCleanUpConstants.JUNIT_CLEANUP_4_IGNORE);
context4junit4.enable(MYCleanUpConstants.JUNIT_CLEANUP_4_TEST);
context4junit4.enable(MYCleanUpConstants.JUNIT_CLEANUP_4_RULETEMPORARYFOLDER);
context4junit4.enable(MYCleanUpConstants.JUNIT_CLEANUP_4_RULETESTNAME);
context4junit4.enable(MYCleanUpConstants.JUNIT_CLEANUP_4_EXTERNALRESOURCE);
context4junit4.enable(MYCleanUpConstants.JUNIT_CLEANUP_4_RUNWITH);
context4junit4.assertRefactoringResultAsExpected(new ICompilationUnit[] {cu,cu2}, new String[] {
"""
package test;
Expand Down Expand Up @@ -989,6 +1016,19 @@ public start(){
}
""", false, null); //$NON-NLS-1$
context4junit4.enable(MYCleanUpConstants.JUNIT_CLEANUP);
context4junit4.enable(MYCleanUpConstants.JUNIT_CLEANUP_4_ASSERT);
context4junit4.enable(MYCleanUpConstants.JUNIT_CLEANUP_4_ASSUME);
context4junit4.enable(MYCleanUpConstants.JUNIT_CLEANUP_4_SUITE);
context4junit4.enable(MYCleanUpConstants.JUNIT_CLEANUP_4_BEFORE);
context4junit4.enable(MYCleanUpConstants.JUNIT_CLEANUP_4_AFTER);
context4junit4.enable(MYCleanUpConstants.JUNIT_CLEANUP_4_BEFORECLASS);
context4junit4.enable(MYCleanUpConstants.JUNIT_CLEANUP_4_AFTERCLASS);
context4junit4.enable(MYCleanUpConstants.JUNIT_CLEANUP_4_IGNORE);
context4junit4.enable(MYCleanUpConstants.JUNIT_CLEANUP_4_TEST);
context4junit4.enable(MYCleanUpConstants.JUNIT_CLEANUP_4_RULETEMPORARYFOLDER);
context4junit4.enable(MYCleanUpConstants.JUNIT_CLEANUP_4_RULETESTNAME);
context4junit4.enable(MYCleanUpConstants.JUNIT_CLEANUP_4_EXTERNALRESOURCE);
context4junit4.enable(MYCleanUpConstants.JUNIT_CLEANUP_4_RUNWITH);
context4junit4.assertRefactoringResultAsExpected(new ICompilationUnit[] {cu,cu2}, new String[] {
"""
package test;
Expand Down Expand Up @@ -1082,6 +1122,19 @@ protected void after() {
}
""", false, null); //$NON-NLS-1$
context4junit4.enable(MYCleanUpConstants.JUNIT_CLEANUP);
context4junit4.enable(MYCleanUpConstants.JUNIT_CLEANUP_4_ASSERT);
context4junit4.enable(MYCleanUpConstants.JUNIT_CLEANUP_4_ASSUME);
context4junit4.enable(MYCleanUpConstants.JUNIT_CLEANUP_4_SUITE);
context4junit4.enable(MYCleanUpConstants.JUNIT_CLEANUP_4_BEFORE);
context4junit4.enable(MYCleanUpConstants.JUNIT_CLEANUP_4_AFTER);
context4junit4.enable(MYCleanUpConstants.JUNIT_CLEANUP_4_BEFORECLASS);
context4junit4.enable(MYCleanUpConstants.JUNIT_CLEANUP_4_AFTERCLASS);
context4junit4.enable(MYCleanUpConstants.JUNIT_CLEANUP_4_IGNORE);
context4junit4.enable(MYCleanUpConstants.JUNIT_CLEANUP_4_TEST);
context4junit4.enable(MYCleanUpConstants.JUNIT_CLEANUP_4_RULETEMPORARYFOLDER);
context4junit4.enable(MYCleanUpConstants.JUNIT_CLEANUP_4_RULETESTNAME);
context4junit4.enable(MYCleanUpConstants.JUNIT_CLEANUP_4_EXTERNALRESOURCE);
context4junit4.enable(MYCleanUpConstants.JUNIT_CLEANUP_4_RUNWITH);
context4junit4.assertRefactoringResultAsExpected(new ICompilationUnit[] {cu,cu2,cu3}, new String[] {
"""
package test;
Expand Down
Binary file not shown.
16 changes: 6 additions & 10 deletions sandbox_product/sandbox.product
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<?pde version="3.5"?>

<product name="Sandbox Product" uid="sandbox.bundle.producteclipse" id="org.eclipse.platform.ide" application="org.eclipse.ui.ide.workbench" version="1.2.0.qualifier" type="features" includeLaunchers="false" autoIncludeRequirements="true">
<product name="Sandbox Product" uid="sandbox.bundle.producteclipse" id="org.eclipse.platform.ide" application="org.sandbox.jdt.core.JavaCleanup" version="1.2.0.qualifier" type="features" includeLaunchers="false" autoIncludeRequirements="true">

<configIni use="default">
</configIni>
Expand Down Expand Up @@ -196,16 +196,7 @@ United States, other countries, or both.
<feature id="org.eclipse.rcp"/>
<feature id="org.eclipse.e4.rcp"/>
<feature id="org.eclipse.equinox.p2.core.feature"/>
<feature id="org.eclipse.ecf.core.feature"/>
<feature id="org.eclipse.ecf.filetransfer.feature"/>
<feature id="org.eclipse.ecf.filetransfer.ssl.feature"/>
<feature id="org.eclipse.ecf.core.ssl.feature"/>
<feature id="org.eclipse.equinox.p2.extras.feature"/>
<feature id="org.eclipse.ecf.filetransfer.httpclient5.feature"/>
<feature id="org.eclipse.ecf.filetransfer.httpclientjava.feature"/>
<feature id="org.eclipse.emf.compare"/>
<feature id="org.eclipse.jgit"/>
<feature id="org.eclipse.jgit.ssh.apache"/>
<feature id="sandbox_encoding_quickfix_feature"/>
<feature id="sandbox_extra_search_feature"/>
<feature id="sandbox_usage_view_feature"/>
Expand All @@ -214,6 +205,11 @@ United States, other countries, or both.
<feature id="sandbox_xml_cleanup_feature"/>
<feature id="sandbox_jface_cleanup_feature"/>
<feature id="sandbox_junit_cleanup_feature"/>
<feature id="org.eclipse.pde" installMode="root"/>
<feature id="org.eclipse.jdt" installMode="root"/>
<feature id="org.eclipse.equinox.p2.user.ui" installMode="root"/>
<feature id="org.eclipse.equinox.p2.rcp.feature" installMode="root"/>
<feature id="org.eclipse.platform" installMode="root"/>
</features>

<configurations>
Expand Down
Loading

0 comments on commit 8ddac4c

Please sign in to comment.