Run Tests & Build in Eclipse
Execute JUnit tests and Maven builds using Eclipse's built-in infrastructure.
Test Tools
- runAllTests — Run all tests in a project. Provide
projectNameand optionaltimeout(default: 60s). - runPackageTests — Run tests in a specific package. Provide
projectNameandpackageName. - runClassTests — Run all tests in a specific test class. Provide
projectNameandclassName(fully qualified). - runTestMethod — Run a single test method. Provide
projectName,className, andmethodName. - findTestClasses — Find and classify tests as plain JUnit or PDE harness tests. PDE tests must use the
*PDETest.javanaming convention; likely harness-dependent misnamed tests are reported as warnings.
PDE Harness Tests
- runJUnitPluginTests — Run all plug-in tests in the PDE harness. Use for the classes listed under
PDE harness tests (*PDETest). - runJUnitPluginTestClass — Run one fully qualified
*PDETestclass. - runJUnitPluginTestClasses — Run a comma-separated set of fully qualified
*PDETestclasses in one PDE launch. Prefer it after a change touches several harness tests because Eclipse workbench startup is paid only once. The initial batch tool does not provide coverage; use the single-class or whole-project tools when coverage is required. - getActiveTarget / reloadTarget — Inspect or refresh the target platform when plug-in dependencies cannot resolve.
- Keep ordinary unit tests named
*Test.java; any test using Eclipse workspace, JDT, UI, platform, or OSGi runtime services must be named*PDETest.javaso discovery routes it to the PDE harness.
Build Tools
- runMavenBuild — Run Maven the way Run As > Maven build does. Provide
projectNameandgoalswritten exactly as aftermvn(e.g.,clean install -DskipTests -pl module); optionalprofiles,properties,pomDirectory,offline,skipTests, andtimeout(seconds to wait before an operationId is returned). The result carries the exit code, every[ERROR]line and the tail of the log; the full log is in the console namedlaunchName. - getEffectivePom — Get the effective POM for a Maven project.
- listMavenProjects — List all Maven projects in the workspace.
- getProjectDependencies — Get Maven dependencies for a project.
Typical Workflow
Find test classes:
findTestClasses(projectName="myapp")Run specific test after code change:
runClassTests(projectName="myapp", className="com.example.MyServiceTest", timeout="60")Run all tests before committing:
runAllTests(projectName="myapp", timeout="120")Build with Maven:
runMavenBuild(projectName="myapp", goals="clean verify -DskipTests", timeout="300")Check build output:
getConsoleOutput()
Notes
- Tests run using JUnit 5 by default
- Run plain tests with
runClassTests/runAllTests; run*PDETestclasses with theeclipse-pdeharness tools - Test results include pass/fail status, execution time, and failure traces
- Use
getCompilationErrorsfirst to ensure code compiles before running tests - Maven build output goes to the Eclipse console — use
getConsoleOutputto retrieve it