Skip to content

Commit

Permalink
JUnit 5 migration - gcov
Browse files Browse the repository at this point in the history
  • Loading branch information
akurtakov committed Sep 3, 2024
1 parent 4baac0f commit 5bd0073
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 25 deletions.
2 changes: 1 addition & 1 deletion gcov/org.eclipse.linuxtools.gcov.test/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Bundle-Name: %bundleName
Bundle-SymbolicName: org.eclipse.linuxtools.gcov.test
Bundle-Version: 4.1.1.qualifier
Bundle-Vendor: %bundleProvider
Require-Bundle: org.junit;bundle-version="4.10.0",
Require-Bundle: junit-jupiter-api, junit-platform-suite-api,
org.eclipse.linuxtools.gcov.launch;bundle-version="1.0.0",
org.eclipse.cdt.managedbuilder.gnu.ui;bundle-version="8.0.0",
org.eclipse.linuxtools.profiling.tests,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
*******************************************************************************/
package org.eclipse.linuxtools.internal.gcov.test;

import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.platform.suite.api.SelectClasses;
import org.junit.platform.suite.api.Suite;

@RunWith(Suite.class)
@Suite.SuiteClasses({
@Suite
@SelectClasses({
GcovTestC.class,
GcovTestCPP.class,
GcovTestCLibrary.class
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
*******************************************************************************/
package org.eclipse.linuxtools.internal.gcov.test;

import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.fail;

import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -54,12 +57,11 @@
import org.eclipse.ui.WorkbenchException;
import org.eclipse.ui.navigator.CommonNavigator;
import org.eclipse.ui.navigator.resources.ProjectExplorer;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.osgi.framework.FrameworkUtil;

public abstract class GcovTest extends AbstractTest {
Expand All @@ -75,7 +77,7 @@ public abstract class GcovTest extends AbstractTest {
abstract protected boolean useDefaultBin();
abstract protected boolean getTestProducedReference();

@BeforeClass
@BeforeAll
public static void init() {
display = Display.getDefault();
display.syncExec(() -> {
Expand All @@ -87,12 +89,12 @@ public static void init() {
}
PlatformUI.getWorkbench().showPerspective(CUIPlugin.ID_CPERSPECTIVE, window);
} catch (WorkbenchException e) {
Assert.fail("Couldn't open C/C++ perspective.");
fail("Couldn't open C/C++ perspective.");
}
});
}

@Before
@BeforeEach
public void setUp() throws Exception {
if (project == null) {
ICProject cproject = createProjectAndBuild(FrameworkUtil.getBundle(this.getClass()), getTestProjectName());
Expand All @@ -113,7 +115,7 @@ public void setUp() throws Exception {
}
}

@After
@AfterEach
public void cleanUp() {
display.syncExec(() -> {
Shell[] shells = Display.getCurrent().getShells();
Expand All @@ -127,12 +129,12 @@ public void cleanUp() {
});
}

@AfterClass
@AfterAll
public static void finalCleanUp() {
try {
project.delete(true, null);
} catch (CoreException e) {
Assert.fail("Project deletion failed");
fail("Project deletion failed");
} finally {
project = null;
}
Expand Down Expand Up @@ -164,7 +166,7 @@ private void testGcovFileDetails(final String filename, final String binPath) {
return;
}
}
Assert.fail("Editor for file " + targetFile + " was not opened,"
fail("Editor for file " + targetFile + " was not opened,"
+ " instead opened " + openedFile + ".");
}
});
Expand Down Expand Up @@ -193,7 +195,7 @@ private void testGcovSummary(final String filename, String binPath,
csvAction = (STExportToCSVAction) ((ActionContributionItem) item).getAction();
}
}
Assert.assertNotNull("CSV-Export toolbar button does not exist.", csvAction);
assertNotNull(csvAction, "CSV-Export toolbar button does not exist.");

for (IContributionItem item : items) {
if (item instanceof ActionContributionItem) {
Expand Down Expand Up @@ -262,12 +264,12 @@ public void testGcovSummaryByLaunch() {
}
}
} catch (PartInitException e1) {
Assert.fail("Cannot show Project Explorer.");
fail("Cannot show Project Explorer.");
}
try {
window.getActivePage().showView("org.eclipse.linuxtools.gcov.view");
} catch (PartInitException e2) {
Assert.fail("Cannot show GCov View.");
fail("Cannot show GCov View.");
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
*******************************************************************************/
package org.eclipse.linuxtools.internal.gcov.test;

import org.junit.jupiter.api.Test;

public class GcovTestCLibrary extends GcovTest {

@Override
Expand All @@ -35,6 +37,7 @@ protected boolean useDefaultBin() {
return false;
}

@Test
@Override
public void testGcovSummaryByLaunch() {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
*******************************************************************************/
package org.eclipse.linuxtools.internal.gcov.test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.fail;

import java.io.File;
import java.io.FileNotFoundException;
Expand Down Expand Up @@ -85,7 +85,7 @@ public static String getAbsolutePath(String pluginId, String relativeName) {
try {
url = FileLocator.toFileURL(url);
} catch (IOException e) {
assertNotNull("Problem locating " + relativeName + " in" + pluginId,e);
assertNotNull(e, "Problem locating " + relativeName + " in" + pluginId);
}
String filename = url.getFile();
return filename;
Expand Down

0 comments on commit 5bd0073

Please sign in to comment.