-
Couldn't load subscription status.
- Fork 557
Add basic integration test for JUnit 5 #118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
2df5945
0111d35
8d84a9c
bdda605
65c6e75
a6f1e4c
120f89d
0c62d45
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| package org.apache.maven.surefire.its; | ||
|
|
||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; | ||
| import org.junit.Test; | ||
|
|
||
| import static org.apache.commons.lang3.JavaVersion.JAVA_1_8; | ||
| import static org.apache.maven.surefire.its.fixture.HelperAssertions.assumeJavaVersion; | ||
|
|
||
| /** | ||
| * Basic suite test currently only running against JUnit 5 M2 | ||
| * | ||
| * @author <a href="mailto:britter@apache.org">Benedikt Ritter</a> | ||
| */ | ||
| public class JUnit5IT | ||
| extends SurefireJUnit4IntegrationTestCase | ||
| { | ||
|
|
||
| @Test | ||
| public void test() | ||
| { | ||
| assumeJavaVersion( JAVA_1_8 ); | ||
|
|
||
| unpack( "/junit5" ).executeTest().verifyErrorFree( 2 ); | ||
| } | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <!-- | ||
| ~ Licensed to the Apache Software Foundation (ASF) under one | ||
| ~ or more contributor license agreements. See the NOTICE file | ||
| ~ distributed with this work for additional information | ||
| ~ regarding copyright ownership. The ASF licenses this file | ||
| ~ to you under the Apache License, Version 2.0 (the | ||
| ~ "License"); you may not use this file except in compliance | ||
| ~ with the License. You may obtain a copy of the License at | ||
| ~ | ||
| ~ http://www.apache.org/licenses/LICENSE-2.0 | ||
| ~ | ||
| ~ Unless required by applicable law or agreed to in writing, | ||
| ~ software distributed under the License is distributed on an | ||
| ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| ~ KIND, either express or implied. See the License for the | ||
| ~ specific language governing permissions and limitations | ||
| ~ under the License. | ||
| --> | ||
|
|
||
| <project xmlns="http://maven.apache.org/POM/4.0.0" | ||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
| <modelVersion>4.0.0</modelVersion> | ||
|
|
||
| <groupId>org.apache.maven.plugins.surefire</groupId> | ||
| <artifactId>junit5</artifactId> | ||
| <version>1.0-SNAPSHOT</version> | ||
| <name>Test for JUnit 5</name> | ||
|
|
||
| <properties> | ||
| <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
| <java.version>1.8</java.version> | ||
| <junit.jupiter.version>5.0.0-M2</junit.jupiter.version> | ||
| <junit.vintage.version>4.12.0-M2</junit.vintage.version> | ||
| <junit.platform.version>1.0.0-M2</junit.platform.version> | ||
| </properties> | ||
|
|
||
| <dependencies> | ||
| <dependency> | ||
| <groupId>org.junit.jupiter</groupId> | ||
| <artifactId>junit-jupiter-engine</artifactId> | ||
| <version>${junit.jupiter.version}</version> | ||
| <scope>test</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.junit.vintage</groupId> | ||
| <artifactId>junit-vintage-engine</artifactId> | ||
| <version>${junit.vintage.version}</version> | ||
| <scope>test</scope> | ||
| </dependency> | ||
| </dependencies> | ||
|
|
||
| <build> | ||
| <plugins> | ||
| <plugin> | ||
| <artifactId>maven-compiler-plugin</artifactId> | ||
| <configuration> | ||
| <source>${java.version}</source> | ||
| <target>${java.version}</target> | ||
| </configuration> | ||
| </plugin> | ||
| <plugin> | ||
| <artifactId>maven-surefire-plugin</artifactId> | ||
| <version>${surefire.version}</version> | ||
| <dependencies> | ||
| <dependency> | ||
| <groupId>org.junit.platform</groupId> | ||
| <artifactId>junit-platform-surefire-provider</artifactId> | ||
| <version>${junit.platform.version}</version> | ||
| </dependency> | ||
| </dependencies> | ||
| </plugin> | ||
| </plugins> | ||
| </build> | ||
|
|
||
| </project> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| package junit5; | ||
|
|
||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| import org.junit.After; | ||
| import org.junit.AfterClass; | ||
| import org.junit.Assert; | ||
| import org.junit.Before; | ||
| import org.junit.Test; | ||
|
|
||
| /** | ||
| * A test using the JUnit 4 API, which should be executed by JUnit vintage enigne | ||
| */ | ||
| public class JUnit4Test | ||
| { | ||
|
|
||
| private boolean setUpCalled; | ||
|
|
||
| private static boolean tearDownCalled; | ||
|
|
||
| @Before | ||
| public void setUp() | ||
| { | ||
| setUpCalled = true; | ||
| System.out.println( "Called setUp" ); | ||
| } | ||
|
|
||
| @After | ||
| public void tearDown() | ||
| { | ||
| tearDownCalled = true; | ||
| System.out.println( "Called tearDown" ); | ||
| } | ||
|
|
||
| @Test | ||
| public void testSetUp() | ||
| { | ||
| Assert.assertTrue( "setUp was not called", setUpCalled ); | ||
| } | ||
|
|
||
| @AfterClass | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing BeforeClass and assertion statement that it was called. If the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I copied this test from the /junit-4 directory. We probably have to fix that test also. |
||
| public static void oneTimeTearDown() | ||
| { | ||
| Assert.assertTrue( "tearDown was not called", tearDownCalled ); | ||
| } | ||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| package junit5; | ||
|
|
||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| import org.junit.jupiter.api.AfterEach; | ||
| import org.junit.jupiter.api.AfterAll; | ||
| import org.junit.jupiter.api.Assertions; | ||
| import org.junit.jupiter.api.BeforeEach; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
||
|
|
||
| /** | ||
| * A test using the JUnit 5 API, which should be executed by JUnit jupiter enigne | ||
| */ | ||
| public class JUnit5Test | ||
| { | ||
|
|
||
| private boolean setUpCalled; | ||
|
|
||
| private static boolean tearDownCalled; | ||
|
|
||
| @BeforeEach | ||
| public void setUp() | ||
| { | ||
| setUpCalled = true; | ||
| System.out.println( "Called setUp" ); | ||
| } | ||
|
|
||
| @AfterEach | ||
| public void tearDown() | ||
| { | ||
| tearDownCalled = true; | ||
| System.out.println( "Called tearDown" ); | ||
| } | ||
|
|
||
| @Test | ||
| public void testSetUp() | ||
| { | ||
| Assertions.assertTrue( setUpCalled, "setUp was not called" ); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's up to your taste:) |
||
| } | ||
|
|
||
| @AfterAll | ||
| public static void oneTimeTearDown() | ||
| { | ||
| Assertions.assertTrue( tearDownCalled, "tearDown was not called" ); | ||
| } | ||
|
|
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the first IT.
I should study what these dependencies mean :)