Skip to content

Commit

Permalink
Provide tycho-surefire integration test for JUnit 5 suites
Browse files Browse the repository at this point in the history
Contributes to #2462
  • Loading branch information
HeikoKlare committed Jan 10, 2024
1 parent 86db29d commit c910c08
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: JUnit5 Suite Test Plug-in
Bundle-SymbolicName: bundle.test.junit5suite
Bundle-Version: 1.0.0
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Import-Package: org.junit.jupiter.api;version="5.0",
org.junit.platform.suite.api
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.
37 changes: 37 additions & 0 deletions tycho-its/projects/surefire.junit5suite/bundle.test/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>org.eclipse.tycho.tycho-its.surefire-junit5</groupId>
<artifactId>bundle.test.junit5suite</artifactId>
<packaging>eclipse-test-plugin</packaging>
<version>1.0.0</version>

<repositories>
<repository>
<id>eclipse</id>
<layout>p2</layout>
<url>${target-platform}</url>
</repository>
</repositories>

<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-maven-plugin</artifactId>
<version>${tycho-version}</version>
<extensions>true</extensions>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-surefire-plugin</artifactId>
<version>${tycho-version}</version>
<configuration>
<includes>
<include>**/SuiteWithAllTests.java</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*******************************************************************************
* Copyright (c) 2023 Vector Informatik GmbH and others.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Vector Informatik GmbH - initial API and implementation
*******************************************************************************/
package bundle.test;

import static org.junit.jupiter.api.Assertions.assertEquals;

import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

class JUnit5Test {

@Test
@DisplayName("started from test suite")
void startedFromSuite() {
assertEquals(2, 1 + 1);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*******************************************************************************
* Copyright (c) 2023 Vector Informatik GmbH and others.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Vector Informatik GmbH - initial API and implementation
*******************************************************************************/
package bundle.test;

import org.junit.platform.suite.api.Suite;
import org.junit.platform.suite.api.SelectClasses;

@Suite
@SelectClasses({ JUnit5Test.class })
public class SuiteWithAllTests {

}
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,15 @@ public void testJUnit59Runner() throws Exception {
// make sure test tagged as 'slow' was skipped
assertNumberOfSuccessfulTests(projectBasedir, "bundle.test.JUnit59Test", 4);
}

@Test
public void testJUnit5Suite() throws Exception {
final Verifier verifier = getVerifier("/surefire.junit5suite/bundle.test");
verifier.executeGoal("verify");
verifier.verifyErrorFreeLog();
final String projectBasedir = verifier.getBasedir();
// make sure tests from suite were executed
assertNumberOfSuccessfulTests(projectBasedir, "bundle.test.SuiteWithAllTests", 1);
}

}

0 comments on commit c910c08

Please sign in to comment.