-
Notifications
You must be signed in to change notification settings - Fork 194
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[backport] Add support for JUnit 'vintage' attribute on classpath
JDT supports a new classpath attribute on the JUnit5 container that disables the vintage engine. This is especially important if one wants to write plain JUnit5 test as it is otherwise easy to mix up Junit4/5. This now adds a testcase that shows that such mixed usage would fail compilation. (cherry picked from commit 13489c6)
- Loading branch information
Showing
12 changed files
with
291 additions
and
9 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
tycho-its/projects/surefire.combinedtests/bundle5.no.vintage.test/.classpath
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" path="src"/> | ||
<classpathentry kind="src" output="test" path="src_test"> | ||
<attributes> | ||
<attribute name="test" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="src" path="src2"/> | ||
<classpathentry kind="src" output="test" path="integration-tests"> | ||
<attributes> | ||
<attribute name="test" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11"> | ||
<attributes> | ||
<attribute name="module" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5"> | ||
<attributes> | ||
<attribute name="vintage" value="false" /> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="output" path="bin"/> | ||
</classpath> |
9 changes: 9 additions & 0 deletions
9
tycho-its/projects/surefire.combinedtests/bundle5.no.vintage.test/META-INF/MANIFEST.MF
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Manifest-Version: 1.0 | ||
Bundle-ManifestVersion: 2 | ||
Bundle-Name: Test Plug-in | ||
Bundle-SymbolicName: bundle.test5 | ||
Bundle-Version: 1.0.0 | ||
Import-Package: javax.annotation, | ||
org.osgi.framework | ||
Automatic-Module-Name: bundle.test5 | ||
Bundle-RequiredExecutionEnvironment: JavaSE-11 |
4 changes: 4 additions & 0 deletions
4
tycho-its/projects/surefire.combinedtests/bundle5.no.vintage.test/build.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
source.. = src/,src2/ | ||
output.. = bin/ | ||
bin.includes = META-INF/,\ | ||
. |
49 changes: 49 additions & 0 deletions
49
tycho-its/projects/surefire.combinedtests/bundle5.no.vintage.test/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>org.eclipse.tycho.tycho-its.surefire</groupId> | ||
<artifactId>bundle.test5</artifactId> | ||
<packaging>eclipse-plugin</packaging> | ||
<version>1.0.0</version> | ||
<properties> | ||
<target-platform>https:////download.eclipse.org/releases/2022-12/</target-platform> | ||
<tycho-version>4.0.0-SNAPSHOT</tycho-version> | ||
</properties> | ||
<repositories> | ||
<repository> | ||
<id>platform</id> | ||
<url>${target-platform}</url> | ||
<layout>p2</layout> | ||
</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.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<version>3.0.0-M5</version> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.apache.maven.surefire</groupId> | ||
<artifactId>surefire-junit47</artifactId> | ||
<version>3.0.0-M5</version> | ||
</dependency> | ||
</dependencies> | ||
<executions> | ||
<execution> | ||
<id>execute-tests</id> | ||
<goals> | ||
<goal>test</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
38 changes: 38 additions & 0 deletions
38
...ts/projects/surefire.combinedtests/bundle5.no.vintage.test/src/bundle/test/CountDown.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2021 Christoph Läubrich 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: | ||
* Christoph Läubrich. - initial API and implementation | ||
*******************************************************************************/ | ||
package bundle.test; | ||
|
||
public class CountDown { | ||
|
||
RefMe refFromOtherSourceFolder; | ||
|
||
int count; | ||
|
||
public CountDown(int initalValue) { | ||
count = initalValue; | ||
} | ||
|
||
public void decrement(int x) { | ||
if (x < 0) { | ||
throw new IllegalArgumentException(); | ||
} | ||
if (count-x < 0) { | ||
throw new IllegalStateException(); | ||
} | ||
count -= x; | ||
} | ||
|
||
public int get() { | ||
return count; | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
...-its/projects/surefire.combinedtests/bundle5.no.vintage.test/src/bundle/test/Counter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2021 Christoph Läubrich 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: | ||
* Christoph Läubrich. - initial API and implementation | ||
*******************************************************************************/ | ||
package bundle.test; | ||
|
||
public class Counter { | ||
|
||
int count; | ||
|
||
public void increment(int x) { | ||
if (x < 0) { | ||
throw new IllegalArgumentException(); | ||
} | ||
count += x; | ||
} | ||
|
||
public int get() { | ||
return count; | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...o-its/projects/surefire.combinedtests/bundle5.no.vintage.test/src2/bundle/test/RefMe.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2021 Christoph Läubrich 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: | ||
* Christoph Läubrich. - initial API and implementation | ||
*******************************************************************************/ | ||
|
||
package bundle.test; | ||
|
||
public class RefMe extends Counter{ | ||
|
||
} |
35 changes: 35 additions & 0 deletions
35
...ojects/surefire.combinedtests/bundle5.no.vintage.test/src_test/bundle/test/AdderTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2021 Christoph Läubrich 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: | ||
* Christoph Läubrich. - initial API and implementation | ||
*******************************************************************************/ | ||
package bundle.test; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
|
||
public class AdderTest { | ||
|
||
@org.junit.jupiter.api.Test | ||
public void incrementTest() { | ||
Counter counter = new Counter(); | ||
counter.increment(1); | ||
counter.increment(3); | ||
assertEquals(4, counter.get()); | ||
} | ||
|
||
@org.junit.jupiter.api.Test | ||
public void decrementTest() { | ||
assertThrows(IllegalArgumentException.class, ()->{ | ||
Counter counter = new Counter(); | ||
counter.increment(-1); | ||
}); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
...s/surefire.combinedtests/bundle5.no.vintage.test/src_test/bundle/test/SubtractorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2021 Christoph Läubrich 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: | ||
* Christoph Läubrich - initial API and implementation | ||
*******************************************************************************/ | ||
package bundle.test; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import org.junit.Test; | ||
|
||
public class SubtractorTest { | ||
|
||
@Test | ||
public void incrementTest() { | ||
CountDown counter = new CountDown(10); | ||
counter.decrement(1); | ||
counter.decrement(3); | ||
assertEquals(6, counter.get()); | ||
} | ||
|
||
@Test(expected = IllegalArgumentException.class) | ||
public void decrementTest() { | ||
CountDown counter = new CountDown(10); | ||
counter.decrement(-1); | ||
} | ||
|
||
@Test(expected = IllegalStateException.class) | ||
public void decrementTest2() { | ||
CountDown counter = new CountDown(1); | ||
counter.decrement(5); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters