This API is typically used by IDEs and build tools.
5 | */
6 |
7 | package org.junit.gen5.launcher;
8 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: java
2 |
3 | sudo: required
4 |
5 | jdk:
6 | - oraclejdk8
7 |
8 | install: true
9 |
10 | script:
11 | - sudo apt-get update && sudo apt-get install oracle-java8-installer
12 | - java -version
13 | - ./gradlew check
14 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | version = 5.0.0-SNAPSHOT
2 | group = org.junit
3 |
4 | assertJVersion = 3.2.0
5 | junit4Version = 4.12
6 | log4JVersion = 2.5
7 | mockitoVersion = 1.10.19
8 | ota4jVersion = 1.0.0-ALPHA
9 | degraphVersion = 0.1.3
10 |
--------------------------------------------------------------------------------
/junit-engine-api/src/main/java/org/junit/gen5/engine/support/filter/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * {@link org.junit.gen5.engine.Filter}-related support classes intended to be
3 | * used by test engine implementations.
4 | */
5 |
6 | package org.junit.gen5.engine.support.filter;
7 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Thu Dec 24 12:48:01 CET 2015
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
7 |
--------------------------------------------------------------------------------
/junit4-runner/src/main/java/org/junit/gen5/junit4/runner/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * {@code Runner} and annotations for configuring and executing tests that
3 | * use the JUnit 5 programming and extension models in a JUnit 4 environment.
4 | */
5 |
6 | package org.junit.gen5.junit4.runner;
7 |
--------------------------------------------------------------------------------
/surefire-junit5/build.gradle:
--------------------------------------------------------------------------------
1 | dependencies {
2 | compile('org.apache.maven.surefire:surefire-api:2.19')
3 | compile('org.apache.maven.surefire:common-java5:2.19')
4 | compile(project(':junit-launcher'))
5 | runtime(project(':junit5-engine'))
6 | runtime(project(':junit4-engine'))
7 | }
8 |
--------------------------------------------------------------------------------
/junit-engine-api/src/main/java/org/junit/gen5/engine/support/descriptor/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * {@link org.junit.gen5.engine.TestDescriptor}-related support classes
3 | * intended to be used by test engine implementations.
4 | */
5 |
6 | package org.junit.gen5.engine.support.descriptor;
7 |
--------------------------------------------------------------------------------
/junit-engine-api/src/main/java/org/junit/gen5/engine/support/hierarchical/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Base hierarchical implementation of execution part of
3 | * {@link org.junit.gen5.engine.TestEngine} to be used by test engine
4 | * implementations.
5 | */
6 |
7 | package org.junit.gen5.engine.support.hierarchical;
8 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Gradle
2 | .gradle
3 | build/
4 |
5 | # Ignore Gradle GUI config
6 | gradle-app.setting
7 |
8 | # Eclipse
9 | .classpath
10 | .settings/
11 | .project
12 | bin/
13 |
14 | # IntelliJ
15 | *.iml
16 | *.ipr
17 | *.iws
18 | *.uml
19 | .idea/
20 |
21 | # Misc
22 | *.log
23 | *.graphml
24 | coverage.db*
25 | clover.license
26 |
--------------------------------------------------------------------------------
/documentation/src/docs/asciidoc/release-notes-5.0.0-ALPHA.adoc:
--------------------------------------------------------------------------------
1 | === Release Notes 5.0.0-ALPHA
2 |
3 | *Date of Release:* February 1, 2016
4 |
5 | *Scope:* First public release of JUnit 5
6 |
7 | ==== Summary of Changes
8 |
9 | Since this is the first public release, the set of changes is the set of features as described in this user guide.
10 |
--------------------------------------------------------------------------------
/junit-launcher/src/main/java/org/junit/gen5/launcher/listeners/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Common {@link org.junit.gen5.launcher.TestExecutionListener
3 | * TestExecutionListener} implementations and related support classes for
4 | * the JUnit {@link org.junit.gen5.launcher.Launcher Launcher}.
5 | */
6 |
7 | package org.junit.gen5.launcher.listeners;
8 |
--------------------------------------------------------------------------------
/junit-gradle/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'groovy'
2 |
3 | jar {
4 | manifest {
5 | attributes 'Main-Class': 'org.junit.gen5.console.ConsoleRunner'
6 | }
7 | }
8 |
9 | dependencies {
10 | compile localGroovy()
11 | compile gradleApi()
12 | testCompile(group: 'org.spockframework', name: 'spock-core', version: '1.0-groovy-2.4') {
13 | transitive = false
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/junit-engine-api/src/main/java/org/junit/gen5/engine/discovery/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Concrete {@linkplain org.junit.gen5.engine.DiscoverySelector selectors} and
3 | * {@linkplain org.junit.gen5.engine.DiscoveryFilter filters} to be used in
4 | * {@linkplain org.junit.gen5.engine.EngineDiscoveryRequest discovery requests}.
5 | */
6 |
7 | package org.junit.gen5.engine.discovery;
8 |
--------------------------------------------------------------------------------
/src/spotless/eclipse-public-license-1.0.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2016 the original author or authors.
3 | *
4 | * All rights reserved. This program and the accompanying materials are
5 | * made available under the terms of the Eclipse Public License v1.0 which
6 | * accompanies this distribution and is available at
7 | *
8 | * http://www.eclipse.org/legal/epl-v10.html
9 | */
10 |
--------------------------------------------------------------------------------
/junit-commons/src/main/java/org/junit/gen5/commons/meta/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Internal meta-annotations.
3 | *
4 | *
DISCLAIMER
5 | *
6 | *
These classes are intended solely for usage within the JUnit framework
7 | * itself. Any usage by external parties is not supported.
8 | * Use at your own risk!
9 | */
10 |
11 | package org.junit.gen5.commons.meta;
12 |
--------------------------------------------------------------------------------
/junit-commons/src/main/java/org/junit/gen5/commons/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Internal common library of JUnit.
3 | *
4 | *
DISCLAIMER
5 | *
6 | *
These utilities are intended solely for usage within the JUnit framework
7 | * itself. Any usage by external parties is not supported.
8 | * Use at your own risk!
9 | */
10 |
11 | package org.junit.gen5.commons;
12 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name = "junit5"
2 |
3 | include "documentation"
4 | include "junit-commons"
5 | include "junit-console"
6 | include "junit-engine-api"
7 | include "junit-gradle"
8 | include "junit-launcher"
9 | include "junit-tests"
10 | include "junit4-engine"
11 | include "junit4-runner"
12 | include "junit5-api"
13 | include "junit5-engine"
14 |
15 | include "surefire-junit5"
16 |
--------------------------------------------------------------------------------
/junit-commons/src/main/java/org/junit/gen5/commons/util/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Internal common utilities for JUnit.
3 | *
4 | *
DISCLAIMER
5 | *
6 | *
These utilities are intended solely for usage within the JUnit framework
7 | * itself. Any usage by external parties is not supported.
8 | * Use at your own risk!
9 | */
10 |
11 | package org.junit.gen5.commons.util;
12 |
--------------------------------------------------------------------------------
/junit-console/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'application'
2 |
3 | dependencies {
4 | compile(project(':junit-launcher'))
5 | compile('net.sf.jopt-simple:jopt-simple:4.9')
6 |
7 | // Added as runtime dependencies for ease of use in manually managed projects
8 | // see: https://github.com/junit-team/junit5/issues/146
9 | runtime(project(':junit4-engine'))
10 | runtime(project(':junit5-engine'))
11 | }
12 |
13 | mainClassName = "org.junit.gen5.console.ConsoleRunner"
14 |
--------------------------------------------------------------------------------
/src/test/resources/log4j2-test.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/documentation/src/test/resources/log4j2-test.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/junit-launcher/src/main/java/org/junit/gen5/launcher/main/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The {@link org.junit.gen5.launcher.main.DefaultLauncher DefaultLauncher}
3 | * class is the main starting point for running all JUnit tests.
4 | *
5 | *
The {@link org.junit.gen5.launcher.main.TestDiscoveryRequestBuilder
6 | * TestDiscoveryRequestBuilder} serves as a small DSL for creating
7 | * {@link org.junit.gen5.launcher.TestDiscoveryRequest TestDiscoveryRequests}.
8 | */
9 |
10 | package org.junit.gen5.launcher.main;
11 |
--------------------------------------------------------------------------------
/junit-tests/src/test/resources/log4j2-test.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/junit-tests/src/test/java/org/junit/gen5/engine/junit5/descriptor/subpackage/ClassWithoutTestCases.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2016 the original author or authors.
3 | *
4 | * All rights reserved. This program and the accompanying materials are
5 | * made available under the terms of the Eclipse Public License v1.0 which
6 | * accompanies this distribution and is available at
7 | *
8 | * http://www.eclipse.org/legal/epl-v10.html
9 | */
10 |
11 | package org.junit.gen5.engine.junit5.descriptor.subpackage;
12 |
13 | public class ClassWithoutTestCases {
14 | }
15 |
--------------------------------------------------------------------------------
/junit-tests/src/test/java/org/junit/gen5/engine/support/hierarchical/DummyEngineExecutionContext.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2016 the original author or authors.
3 | *
4 | * All rights reserved. This program and the accompanying materials are
5 | * made available under the terms of the Eclipse Public License v1.0 which
6 | * accompanies this distribution and is available at
7 | *
8 | * http://www.eclipse.org/legal/epl-v10.html
9 | */
10 |
11 | package org.junit.gen5.engine.support.hierarchical;
12 |
13 | class DummyEngineExecutionContext implements EngineExecutionContext {
14 | }
15 |
--------------------------------------------------------------------------------
/junit-tests/src/test/java/org/junit/gen5/engine/junit4/samples/PlainOldJavaClassWithoutAnyTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2016 the original author or authors.
3 | *
4 | * All rights reserved. This program and the accompanying materials are
5 | * made available under the terms of the Eclipse Public License v1.0 which
6 | * accompanies this distribution and is available at
7 | *
8 | * http://www.eclipse.org/legal/epl-v10.html
9 | */
10 |
11 | package org.junit.gen5.engine.junit4.samples;
12 |
13 | public class PlainOldJavaClassWithoutAnyTest {
14 |
15 | public void doSomething() {
16 | // no-op
17 | }
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/junit-tests/src/test/java/org/junit/gen5/engine/junit5/descriptor/subpackage/Class1WithTestCases.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2016 the original author or authors.
3 | *
4 | * All rights reserved. This program and the accompanying materials are
5 | * made available under the terms of the Eclipse Public License v1.0 which
6 | * accompanies this distribution and is available at
7 | *
8 | * http://www.eclipse.org/legal/epl-v10.html
9 | */
10 |
11 | package org.junit.gen5.engine.junit5.descriptor.subpackage;
12 |
13 | import org.junit.gen5.api.Test;
14 |
15 | public class Class1WithTestCases {
16 |
17 | @Test
18 | void test1() {
19 |
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/junit-tests/src/test/java/org/junit/gen5/engine/junit5/descriptor/subpackage/Class2WithTestCases.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2016 the original author or authors.
3 | *
4 | * All rights reserved. This program and the accompanying materials are
5 | * made available under the terms of the Eclipse Public License v1.0 which
6 | * accompanies this distribution and is available at
7 | *
8 | * http://www.eclipse.org/legal/epl-v10.html
9 | */
10 |
11 | package org.junit.gen5.engine.junit5.descriptor.subpackage;
12 |
13 | import org.junit.gen5.api.Test;
14 |
15 | public class Class2WithTestCases {
16 |
17 | @Test
18 | void test2() {
19 |
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/junit-tests/src/test/java/org/junit/gen5/engine/junit4/samples/junit4/PlainJUnit4TestCaseWithSingleInheritedTestWhichFails.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2016 the original author or authors.
3 | *
4 | * All rights reserved. This program and the accompanying materials are
5 | * made available under the terms of the Eclipse Public License v1.0 which
6 | * accompanies this distribution and is available at
7 | *
8 | * http://www.eclipse.org/legal/epl-v10.html
9 | */
10 |
11 | package org.junit.gen5.engine.junit4.samples.junit4;
12 |
13 | public class PlainJUnit4TestCaseWithSingleInheritedTestWhichFails extends PlainJUnit4TestCaseWithSingleTestWhichFails {
14 | }
15 |
--------------------------------------------------------------------------------
/documentation/src/test/java/example/DisabledClassDemo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2016 the original author or authors.
3 | *
4 | * All rights reserved. This program and the accompanying materials are
5 | * made available under the terms of the Eclipse Public License v1.0 which
6 | * accompanies this distribution and is available at
7 | *
8 | * http://www.eclipse.org/legal/epl-v10.html
9 | */
10 |
11 | package example;
12 |
13 | // tag::user_guide[]
14 | import org.junit.gen5.api.Disabled;
15 | import org.junit.gen5.api.Test;
16 |
17 | @Disabled
18 | class DisabledClassDemo {
19 | @Test
20 | void testWillBeSkipped() {
21 | }
22 | }
23 | // end::user_guide[]
24 |
--------------------------------------------------------------------------------
/documentation/src/test/java/example/TaggingDemo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2016 the original author or authors.
3 | *
4 | * All rights reserved. This program and the accompanying materials are
5 | * made available under the terms of the Eclipse Public License v1.0 which
6 | * accompanies this distribution and is available at
7 | *
8 | * http://www.eclipse.org/legal/epl-v10.html
9 | */
10 |
11 | package example;
12 |
13 | // tag::user_guide[]
14 | import org.junit.gen5.api.*;
15 |
16 | @Tag("fast")
17 | @Tag("model")
18 | class TaggingDemo {
19 |
20 | @Test
21 | @Tag("taxes")
22 | void testingTaxCalculation() {
23 | }
24 |
25 | }
26 | // end::user_guide[]
27 |
--------------------------------------------------------------------------------
/documentation/src/test/java/example/Fast.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2016 the original author or authors.
3 | *
4 | * All rights reserved. This program and the accompanying materials are
5 | * made available under the terms of the Eclipse Public License v1.0 which
6 | * accompanies this distribution and is available at
7 | *
8 | * http://www.eclipse.org/legal/epl-v10.html
9 | */
10 |
11 | package example;
12 |
13 | // tag::user_guide[]
14 | import java.lang.annotation.*;
15 |
16 | import org.junit.gen5.api.*;
17 |
18 | @Target({ ElementType.TYPE, ElementType.METHOD })
19 | @Retention(RetentionPolicy.RUNTIME)
20 | @Tag("fast")
21 | public @interface Fast {
22 | }
23 | // end::user_guide[]
24 |
--------------------------------------------------------------------------------
/documentation/src/test/java/example/FirstJUnit5Tests.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2016 the original author or authors.
3 | *
4 | * All rights reserved. This program and the accompanying materials are
5 | * made available under the terms of the Eclipse Public License v1.0 which
6 | * accompanies this distribution and is available at
7 | *
8 | * http://www.eclipse.org/legal/epl-v10.html
9 | */
10 |
11 | package example;
12 |
13 | // tag::user_guide[]
14 | import static org.junit.gen5.api.Assertions.assertEquals;
15 |
16 | import org.junit.gen5.api.Test;
17 |
18 | class FirstJUnit5Tests {
19 |
20 | @Test
21 | void myFirstTest() {
22 | assertEquals(2, 1 + 1);
23 | }
24 |
25 | }
26 | // end::user_guide[]
27 |
--------------------------------------------------------------------------------
/documentation/src/test/java/example/JUnit4SuiteDemo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2016 the original author or authors.
3 | *
4 | * All rights reserved. This program and the accompanying materials are
5 | * made available under the terms of the Eclipse Public License v1.0 which
6 | * accompanies this distribution and is available at
7 | *
8 | * http://www.eclipse.org/legal/epl-v10.html
9 | */
10 |
11 | package example;
12 |
13 | // tag::user_guide[]
14 | import org.junit.gen5.junit4.runner.JUnit5;
15 | import org.junit.gen5.junit4.runner.Packages;
16 | import org.junit.runner.RunWith;
17 |
18 | @RunWith(JUnit5.class)
19 | @Packages({ "example" })
20 | public class JUnit4SuiteDemo {
21 | }
22 | // end::user_guide[]
23 |
--------------------------------------------------------------------------------
/documentation/src/test/java/example/DisabledTestsDemo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2016 the original author or authors.
3 | *
4 | * All rights reserved. This program and the accompanying materials are
5 | * made available under the terms of the Eclipse Public License v1.0 which
6 | * accompanies this distribution and is available at
7 | *
8 | * http://www.eclipse.org/legal/epl-v10.html
9 | */
10 |
11 | package example;
12 |
13 | // tag::user_guide[]
14 | import org.junit.gen5.api.Disabled;
15 | import org.junit.gen5.api.Test;
16 |
17 | class DisabledTestsDemo {
18 |
19 | @Disabled
20 | @Test
21 | void testWillBeSkipped() {
22 | }
23 |
24 | @Test
25 | void testWillBeExecuted() {
26 | }
27 | }
28 | // end::user_guide[]
29 |
--------------------------------------------------------------------------------
/documentation/src/test/java/example/DisplayNameDemo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2016 the original author or authors.
3 | *
4 | * All rights reserved. This program and the accompanying materials are
5 | * made available under the terms of the Eclipse Public License v1.0 which
6 | * accompanies this distribution and is available at
7 | *
8 | * http://www.eclipse.org/legal/epl-v10.html
9 | */
10 |
11 | package example;
12 |
13 | // tag::user_guide[]
14 | import org.junit.gen5.api.DisplayName;
15 | import org.junit.gen5.api.Test;
16 |
17 | @DisplayName("A special test case")
18 | class DisplayNameDemo {
19 |
20 | @Test
21 | @DisplayName("A nice name, isn't it?")
22 | void testWithANiceName() {
23 | }
24 | }
25 | // end::user_guide[]
26 |
--------------------------------------------------------------------------------
/junit-tests/src/test/java/org/junit/gen5/engine/junit4/samples/junit4/Categories.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2016 the original author or authors.
3 | *
4 | * All rights reserved. This program and the accompanying materials are
5 | * made available under the terms of the Eclipse Public License v1.0 which
6 | * accompanies this distribution and is available at
7 | *
8 | * http://www.eclipse.org/legal/epl-v10.html
9 | */
10 |
11 | package org.junit.gen5.engine.junit4.samples.junit4;
12 |
13 | public class Categories {
14 |
15 | public interface Plain {
16 | }
17 |
18 | public interface Failing {
19 | }
20 |
21 | public interface Skipped {
22 | }
23 |
24 | public interface SkippedWithReason extends Skipped {
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/junit-tests/src/test/java/org/junit/gen5/engine/junit4/samples/junit4/MalformedJUnit4TestCase.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2016 the original author or authors.
3 | *
4 | * All rights reserved. This program and the accompanying materials are
5 | * made available under the terms of the Eclipse Public License v1.0 which
6 | * accompanies this distribution and is available at
7 | *
8 | * http://www.eclipse.org/legal/epl-v10.html
9 | */
10 |
11 | package org.junit.gen5.engine.junit4.samples.junit4;
12 |
13 | import static org.junit.Assert.fail;
14 |
15 | import org.junit.Test;
16 |
17 | public class MalformedJUnit4TestCase {
18 |
19 | @Test
20 | /* not public */ void nonPublicTest() {
21 | fail("this should never be called");
22 | }
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/junit5-engine/src/main/java/org/junit/gen5/engine/junit5/execution/TestInstanceProvider.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2016 the original author or authors.
3 | *
4 | * All rights reserved. This program and the accompanying materials are
5 | * made available under the terms of the Eclipse Public License v1.0 which
6 | * accompanies this distribution and is available at
7 | *
8 | * http://www.eclipse.org/legal/epl-v10.html
9 | */
10 |
11 | package org.junit.gen5.engine.junit5.execution;
12 |
13 | import static org.junit.gen5.commons.meta.API.Usage.Internal;
14 |
15 | import org.junit.gen5.commons.meta.API;
16 |
17 | @FunctionalInterface
18 | @API(Internal)
19 | public interface TestInstanceProvider {
20 |
21 | Object getTestInstance() throws Exception;
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/junit-tests/src/test/java/org/junit/gen5/engine/junit4/samples/junit3/PlainJUnit3TestCaseWithSingleTestWhichFails.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2016 the original author or authors.
3 | *
4 | * All rights reserved. This program and the accompanying materials are
5 | * made available under the terms of the Eclipse Public License v1.0 which
6 | * accompanies this distribution and is available at
7 | *
8 | * http://www.eclipse.org/legal/epl-v10.html
9 | */
10 |
11 | package org.junit.gen5.engine.junit4.samples.junit3;
12 |
13 | import junit.framework.TestCase;
14 |
15 | import org.junit.Assert;
16 |
17 | public class PlainJUnit3TestCaseWithSingleTestWhichFails extends TestCase {
18 |
19 | public void test() {
20 | Assert.fail("this test should fail");
21 | }
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/junit-tests/src/test/java/org/junit/gen5/engine/junit4/samples/junit4/PlainJUnit4TestCaseWithSingleTestWhichFails.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2016 the original author or authors.
3 | *
4 | * All rights reserved. This program and the accompanying materials are
5 | * made available under the terms of the Eclipse Public License v1.0 which
6 | * accompanies this distribution and is available at
7 | *
8 | * http://www.eclipse.org/legal/epl-v10.html
9 | */
10 |
11 | package org.junit.gen5.engine.junit4.samples.junit4;
12 |
13 | import static org.junit.Assert.fail;
14 |
15 | import org.junit.Test;
16 |
17 | public class PlainJUnit4TestCaseWithSingleTestWhichFails {
18 |
19 | @Test
20 | public void failingTest() {
21 | fail("this test should fail");
22 | }
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/junit-tests/src/test/java/org/junit/gen5/engine/junit5/execution/injection/sample/CustomType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2016 the original author or authors.
3 | *
4 | * All rights reserved. This program and the accompanying materials are
5 | * made available under the terms of the Eclipse Public License v1.0 which
6 | * accompanies this distribution and is available at
7 | *
8 | * http://www.eclipse.org/legal/epl-v10.html
9 | */
10 |
11 | package org.junit.gen5.engine.junit5.execution.injection.sample;
12 |
13 | import java.util.Date;
14 |
15 | /**
16 | * @since 5.0
17 | */
18 | public class CustomType {
19 |
20 | private final Date date = new Date();
21 |
22 | @Override
23 | public String toString() {
24 | return "CustomType: " + this.date;
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/junit-tests/src/test/java/org/junit/gen5/engine/junit4/samples/junit4/JUnit4SuiteWithExceptionThrowingRunner.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2016 the original author or authors.
3 | *
4 | * All rights reserved. This program and the accompanying materials are
5 | * made available under the terms of the Eclipse Public License v1.0 which
6 | * accompanies this distribution and is available at
7 | *
8 | * http://www.eclipse.org/legal/epl-v10.html
9 | */
10 |
11 | package org.junit.gen5.engine.junit4.samples.junit4;
12 |
13 | import org.junit.gen5.engine.junit4.samples.junit4.ExceptionThrowingRunner.ChildCount;
14 | import org.junit.runner.RunWith;
15 |
16 | @RunWith(ExceptionThrowingRunner.class)
17 | @ChildCount(1)
18 | public class JUnit4SuiteWithExceptionThrowingRunner {
19 | }
20 |
--------------------------------------------------------------------------------
/junit-tests/src/test/java/org/junit/gen5/engine/junit4/samples/junit4/JUnit4SuiteWithIgnoredJUnit4TestCase.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2016 the original author or authors.
3 | *
4 | * All rights reserved. This program and the accompanying materials are
5 | * made available under the terms of the Eclipse Public License v1.0 which
6 | * accompanies this distribution and is available at
7 | *
8 | * http://www.eclipse.org/legal/epl-v10.html
9 | */
10 |
11 | package org.junit.gen5.engine.junit4.samples.junit4;
12 |
13 | import org.junit.runner.RunWith;
14 | import org.junit.runners.Suite;
15 | import org.junit.runners.Suite.SuiteClasses;
16 |
17 | @RunWith(Suite.class)
18 | @SuiteClasses(IgnoredJUnit4TestCase.class)
19 | public class JUnit4SuiteWithIgnoredJUnit4TestCase {
20 | }
21 |
--------------------------------------------------------------------------------
/junit-tests/src/test/java/org/junit/gen5/engine/junit4/samples/junit4/TestCaseRunWithJUnit5.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2016 the original author or authors.
3 | *
4 | * All rights reserved. This program and the accompanying materials are
5 | * made available under the terms of the Eclipse Public License v1.0 which
6 | * accompanies this distribution and is available at
7 | *
8 | * http://www.eclipse.org/legal/epl-v10.html
9 | */
10 |
11 | package org.junit.gen5.engine.junit4.samples.junit4;
12 |
13 | import org.junit.gen5.junit4.runner.Classes;
14 | import org.junit.gen5.junit4.runner.JUnit5;
15 | import org.junit.runner.RunWith;
16 |
17 | @RunWith(JUnit5.class)
18 | @Classes(PlainJUnit4TestCaseWithSingleTestWhichFails.class)
19 | public class TestCaseRunWithJUnit5 {
20 | }
21 |
--------------------------------------------------------------------------------
/junit-tests/src/test/java/org/junit/gen5/engine/junit4/samples/junit4/JUnit4TestCaseWithExceptionThrowingRunner.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2016 the original author or authors.
3 | *
4 | * All rights reserved. This program and the accompanying materials are
5 | * made available under the terms of the Eclipse Public License v1.0 which
6 | * accompanies this distribution and is available at
7 | *
8 | * http://www.eclipse.org/legal/epl-v10.html
9 | */
10 |
11 | package org.junit.gen5.engine.junit4.samples.junit4;
12 |
13 | import org.junit.gen5.engine.junit4.samples.junit4.ExceptionThrowingRunner.ChildCount;
14 | import org.junit.runner.RunWith;
15 |
16 | @RunWith(ExceptionThrowingRunner.class)
17 | @ChildCount(0)
18 | public class JUnit4TestCaseWithExceptionThrowingRunner {
19 | }
20 |
--------------------------------------------------------------------------------
/junit-tests/src/test/java/org/junit/gen5/engine/junit4/samples/junit4/IgnoredJUnit4TestCase.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2016 the original author or authors.
3 | *
4 | * All rights reserved. This program and the accompanying materials are
5 | * made available under the terms of the Eclipse Public License v1.0 which
6 | * accompanies this distribution and is available at
7 | *
8 | * http://www.eclipse.org/legal/epl-v10.html
9 | */
10 |
11 | package org.junit.gen5.engine.junit4.samples.junit4;
12 |
13 | import static org.junit.Assert.fail;
14 |
15 | import org.junit.Ignore;
16 | import org.junit.Test;
17 |
18 | @Ignore("complete class is ignored")
19 | public class IgnoredJUnit4TestCase {
20 |
21 | @Test
22 | public void test() {
23 | fail("this test is not even discovered");
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/junit-tests/src/test/java/org/junit/gen5/engine/junit4/samples/junit4/JUnit4SuiteOfSuiteWithIgnoredJUnit4TestCase.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2016 the original author or authors.
3 | *
4 | * All rights reserved. This program and the accompanying materials are
5 | * made available under the terms of the Eclipse Public License v1.0 which
6 | * accompanies this distribution and is available at
7 | *
8 | * http://www.eclipse.org/legal/epl-v10.html
9 | */
10 |
11 | package org.junit.gen5.engine.junit4.samples.junit4;
12 |
13 | import org.junit.runner.RunWith;
14 | import org.junit.runners.Suite;
15 | import org.junit.runners.Suite.SuiteClasses;
16 |
17 | @RunWith(Suite.class)
18 | @SuiteClasses(JUnit4SuiteWithIgnoredJUnit4TestCase.class)
19 | public class JUnit4SuiteOfSuiteWithIgnoredJUnit4TestCase {
20 | }
21 |
--------------------------------------------------------------------------------
/junit-console/src/main/java/org/junit/gen5/console/options/CommandLineOptionsParser.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2016 the original author or authors.
3 | *
4 | * All rights reserved. This program and the accompanying materials are
5 | * made available under the terms of the Eclipse Public License v1.0 which
6 | * accompanies this distribution and is available at
7 | *
8 | * http://www.eclipse.org/legal/epl-v10.html
9 | */
10 |
11 | package org.junit.gen5.console.options;
12 |
13 | import static org.junit.gen5.commons.meta.API.Usage.Internal;
14 |
15 | import java.io.Writer;
16 |
17 | import org.junit.gen5.commons.meta.API;
18 |
19 | @API(Internal)
20 | public interface CommandLineOptionsParser {
21 |
22 | CommandLineOptions parse(String... arguments);
23 |
24 | void printHelp(Writer writer);
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/junit-engine-api/src/main/java/org/junit/gen5/engine/DiscoverySelector.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2016 the original author or authors.
3 | *
4 | * All rights reserved. This program and the accompanying materials are
5 | * made available under the terms of the Eclipse Public License v1.0 which
6 | * accompanies this distribution and is available at
7 | *
8 | * http://www.eclipse.org/legal/epl-v10.html
9 | */
10 |
11 | package org.junit.gen5.engine;
12 |
13 | import static org.junit.gen5.commons.meta.API.Usage.Experimental;
14 |
15 | import org.junit.gen5.commons.meta.API;
16 |
17 | /**
18 | * A selector defines location(s) a {@link TestEngine} should lookup tests at.
19 | *
20 | * @since 5.0
21 | * @see EngineDiscoveryRequest
22 | */
23 | @API(Experimental)
24 | public interface DiscoverySelector {
25 | }
26 |
--------------------------------------------------------------------------------
/junit-tests/src/test/java/org/junit/gen5/engine/junit4/samples/junit4/JUnit4TestCaseWithRunnerWithCustomUniqueIds.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2016 the original author or authors.
3 | *
4 | * All rights reserved. This program and the accompanying materials are
5 | * made available under the terms of the Eclipse Public License v1.0 which
6 | * accompanies this distribution and is available at
7 | *
8 | * http://www.eclipse.org/legal/epl-v10.html
9 | */
10 |
11 | package org.junit.gen5.engine.junit4.samples.junit4;
12 |
13 | import org.junit.Assert;
14 | import org.junit.Test;
15 | import org.junit.runner.RunWith;
16 |
17 | @RunWith(RunnerWithCustomUniqueIds.class)
18 | public class JUnit4TestCaseWithRunnerWithCustomUniqueIds {
19 |
20 | @Test
21 | public void test() {
22 | Assert.fail();
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/junit4-engine/src/main/java/org/junit/gen5/engine/junit4/descriptor/RunnerRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2016 the original author or authors.
3 | *
4 | * All rights reserved. This program and the accompanying materials are
5 | * made available under the terms of the Eclipse Public License v1.0 which
6 | * accompanies this distribution and is available at
7 | *
8 | * http://www.eclipse.org/legal/epl-v10.html
9 | */
10 |
11 | package org.junit.gen5.engine.junit4.descriptor;
12 |
13 | import org.junit.runner.Request;
14 | import org.junit.runner.Runner;
15 |
16 | class RunnerRequest extends Request {
17 |
18 | private final Runner runner;
19 |
20 | RunnerRequest(Runner runner) {
21 | this.runner = runner;
22 | }
23 |
24 | @Override
25 | public Runner getRunner() {
26 | return runner;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/junit-tests/src/test/java/org/junit/gen5/engine/junit4/samples/junit4/JUnit4SuiteWithJUnit4TestCaseWithErrorInBeforeClass.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2016 the original author or authors.
3 | *
4 | * All rights reserved. This program and the accompanying materials are
5 | * made available under the terms of the Eclipse Public License v1.0 which
6 | * accompanies this distribution and is available at
7 | *
8 | * http://www.eclipse.org/legal/epl-v10.html
9 | */
10 |
11 | package org.junit.gen5.engine.junit4.samples.junit4;
12 |
13 | import org.junit.runner.RunWith;
14 | import org.junit.runners.Suite;
15 | import org.junit.runners.Suite.SuiteClasses;
16 |
17 | @RunWith(Suite.class)
18 | @SuiteClasses(JUnit4TestCaseWithErrorInBeforeClass.class)
19 | public class JUnit4SuiteWithJUnit4TestCaseWithErrorInBeforeClass {
20 | }
21 |
--------------------------------------------------------------------------------
/junit-tests/src/test/java/org/junit/gen5/engine/junit4/samples/junit4/JUnit4SuiteWithTwoTestCases.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2016 the original author or authors.
3 | *
4 | * All rights reserved. This program and the accompanying materials are
5 | * made available under the terms of the Eclipse Public License v1.0 which
6 | * accompanies this distribution and is available at
7 | *
8 | * http://www.eclipse.org/legal/epl-v10.html
9 | */
10 |
11 | package org.junit.gen5.engine.junit4.samples.junit4;
12 |
13 | import org.junit.runner.RunWith;
14 | import org.junit.runners.Suite;
15 | import org.junit.runners.Suite.SuiteClasses;
16 |
17 | @RunWith(Suite.class)
18 | @SuiteClasses({ PlainJUnit4TestCaseWithTwoTestMethods.class, PlainJUnit4TestCaseWithSingleTestWhichFails.class })
19 | public class JUnit4SuiteWithTwoTestCases {
20 | }
21 |
--------------------------------------------------------------------------------
/junit-tests/src/test/java/org/junit/gen5/launcher/main/LauncherFactoryForTestingPurposesOnly.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2016 the original author or authors.
3 | *
4 | * All rights reserved. This program and the accompanying materials are
5 | * made available under the terms of the Eclipse Public License v1.0 which
6 | * accompanies this distribution and is available at
7 | *
8 | * http://www.eclipse.org/legal/epl-v10.html
9 | */
10 |
11 | package org.junit.gen5.launcher.main;
12 |
13 | import static java.util.Arrays.asList;
14 |
15 | import org.junit.gen5.engine.TestEngine;
16 |
17 | /**
18 | * @since 5.0
19 | */
20 | public class LauncherFactoryForTestingPurposesOnly {
21 |
22 | public static DefaultLauncher createLauncher(TestEngine... engines) {
23 | return new DefaultLauncher(asList(engines));
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/junit-tests/src/test/java/org/junit/gen5/engine/junit4/samples/junit4/PlainJUnit4TestCaseWithSingleTestWhichIsIgnored.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2016 the original author or authors.
3 | *
4 | * All rights reserved. This program and the accompanying materials are
5 | * made available under the terms of the Eclipse Public License v1.0 which
6 | * accompanies this distribution and is available at
7 | *
8 | * http://www.eclipse.org/legal/epl-v10.html
9 | */
10 |
11 | package org.junit.gen5.engine.junit4.samples.junit4;
12 |
13 | import org.junit.Assert;
14 | import org.junit.Ignore;
15 | import org.junit.Test;
16 |
17 | public class PlainJUnit4TestCaseWithSingleTestWhichIsIgnored {
18 |
19 | @Test
20 | @Ignore("ignored test")
21 | public void ignoredTest() {
22 | Assert.fail("this should not be called");
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/documentation/src/test/java/extensions/ExpectToFail.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2016 the original author or authors.
3 | *
4 | * All rights reserved. This program and the accompanying materials are
5 | * made available under the terms of the Eclipse Public License v1.0 which
6 | * accompanies this distribution and is available at
7 | *
8 | * http://www.eclipse.org/legal/epl-v10.html
9 | */
10 |
11 | package extensions;
12 |
13 | import java.lang.annotation.ElementType;
14 | import java.lang.annotation.Retention;
15 | import java.lang.annotation.RetentionPolicy;
16 | import java.lang.annotation.Target;
17 |
18 | import org.junit.gen5.api.extension.ExtendWith;
19 |
20 | @Target({ ElementType.TYPE, ElementType.METHOD })
21 | @Retention(RetentionPolicy.RUNTIME)
22 | @ExtendWith(ExpectToFailExtension.class)
23 | public @interface ExpectToFail {
24 | }
25 |
--------------------------------------------------------------------------------
/junit-tests/src/test/java/org/junit/gen5/engine/junit4/samples/junit4/JUnit4SuiteOfSuiteWithJUnit4TestCaseWithErrorInBeforeClass.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2016 the original author or authors.
3 | *
4 | * All rights reserved. This program and the accompanying materials are
5 | * made available under the terms of the Eclipse Public License v1.0 which
6 | * accompanies this distribution and is available at
7 | *
8 | * http://www.eclipse.org/legal/epl-v10.html
9 | */
10 |
11 | package org.junit.gen5.engine.junit4.samples.junit4;
12 |
13 | import org.junit.runner.RunWith;
14 | import org.junit.runners.Suite;
15 | import org.junit.runners.Suite.SuiteClasses;
16 |
17 | @RunWith(Suite.class)
18 | @SuiteClasses(JUnit4SuiteWithJUnit4TestCaseWithErrorInBeforeClass.class)
19 | public class JUnit4SuiteOfSuiteWithJUnit4TestCaseWithErrorInBeforeClass {
20 | }
21 |
--------------------------------------------------------------------------------
/junit-tests/src/test/java/org/junit/gen5/engine/junit4/samples/junit4/JUnit4SuiteWithPlainJUnit4TestCaseWithSingleTestWhichIsIgnored.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2016 the original author or authors.
3 | *
4 | * All rights reserved. This program and the accompanying materials are
5 | * made available under the terms of the Eclipse Public License v1.0 which
6 | * accompanies this distribution and is available at
7 | *
8 | * http://www.eclipse.org/legal/epl-v10.html
9 | */
10 |
11 | package org.junit.gen5.engine.junit4.samples.junit4;
12 |
13 | import org.junit.runner.RunWith;
14 | import org.junit.runners.Suite;
15 | import org.junit.runners.Suite.SuiteClasses;
16 |
17 | @RunWith(Suite.class)
18 | @SuiteClasses(PlainJUnit4TestCaseWithSingleTestWhichIsIgnored.class)
19 | public class JUnit4SuiteWithPlainJUnit4TestCaseWithSingleTestWhichIsIgnored {
20 | }
21 |
--------------------------------------------------------------------------------
/junit-tests/src/test/java/org/junit/gen5/engine/junit4/samples/junit4/JUnit4SuiteWithJUnit4TestCaseWithAssumptionFailureInBeforeClass.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2016 the original author or authors.
3 | *
4 | * All rights reserved. This program and the accompanying materials are
5 | * made available under the terms of the Eclipse Public License v1.0 which
6 | * accompanies this distribution and is available at
7 | *
8 | * http://www.eclipse.org/legal/epl-v10.html
9 | */
10 |
11 | package org.junit.gen5.engine.junit4.samples.junit4;
12 |
13 | import org.junit.runner.RunWith;
14 | import org.junit.runners.Suite;
15 | import org.junit.runners.Suite.SuiteClasses;
16 |
17 | @RunWith(Suite.class)
18 | @SuiteClasses(JUnit4TestCaseWithAssumptionFailureInBeforeClass.class)
19 | public class JUnit4SuiteWithJUnit4TestCaseWithAssumptionFailureInBeforeClass {
20 | }
21 |
--------------------------------------------------------------------------------
/junit-engine-api/src/main/java/org/junit/gen5/engine/discovery/ClassFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2016 the original author or authors.
3 | *
4 | * All rights reserved. This program and the accompanying materials are
5 | * made available under the terms of the Eclipse Public License v1.0 which
6 | * accompanies this distribution and is available at
7 | *
8 | * http://www.eclipse.org/legal/epl-v10.html
9 | */
10 |
11 | package org.junit.gen5.engine.discovery;
12 |
13 | import static org.junit.gen5.commons.meta.API.Usage.Experimental;
14 |
15 | import org.junit.gen5.commons.meta.API;
16 | import org.junit.gen5.engine.DiscoveryFilter;
17 |
18 | @API(Experimental)
19 | public interface ClassFilter extends DiscoveryFilter> {
20 |
21 | static ClassFilter byNamePattern(String pattern) {
22 | return new ClassNameFilter(pattern);
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/junit-tests/src/test/java/org/junit/gen5/engine/junit5/execution/injection/sample/CustomAnnotation.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2016 the original author or authors.
3 | *
4 | * All rights reserved. This program and the accompanying materials are
5 | * made available under the terms of the Eclipse Public License v1.0 which
6 | * accompanies this distribution and is available at
7 | *
8 | * http://www.eclipse.org/legal/epl-v10.html
9 | */
10 |
11 | package org.junit.gen5.engine.junit5.execution.injection.sample;
12 |
13 | import java.lang.annotation.ElementType;
14 | import java.lang.annotation.Retention;
15 | import java.lang.annotation.RetentionPolicy;
16 | import java.lang.annotation.Target;
17 |
18 | /**
19 | * @since 5.0
20 | */
21 | @Target(ElementType.PARAMETER)
22 | @Retention(RetentionPolicy.RUNTIME)
23 | public @interface CustomAnnotation {
24 | }
25 |
--------------------------------------------------------------------------------
/junit-engine-api/src/main/java/org/junit/gen5/engine/TestSource.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2016 the original author or authors.
3 | *
4 | * All rights reserved. This program and the accompanying materials are
5 | * made available under the terms of the Eclipse Public License v1.0 which
6 | * accompanies this distribution and is available at
7 | *
8 | * http://www.eclipse.org/legal/epl-v10.html
9 | */
10 |
11 | package org.junit.gen5.engine;
12 |
13 | import static org.junit.gen5.commons.meta.API.Usage.Experimental;
14 |
15 | import java.io.Serializable;
16 |
17 | import org.junit.gen5.commons.meta.API;
18 |
19 | @API(Experimental)
20 | public interface TestSource extends Serializable {
21 |
22 | boolean isJavaClass();
23 |
24 | boolean isJavaMethod();
25 |
26 | boolean isDirectory();
27 |
28 | boolean isFile();
29 |
30 | boolean isFilePosition();
31 | }
32 |
--------------------------------------------------------------------------------
/junit-tests/src/test/java/org/junit/gen5/engine/junit4/samples/junit4/SingleFailingTheoryTestCase.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2016 the original author or authors.
3 | *
4 | * All rights reserved. This program and the accompanying materials are
5 | * made available under the terms of the Eclipse Public License v1.0 which
6 | * accompanies this distribution and is available at
7 | *
8 | * http://www.eclipse.org/legal/epl-v10.html
9 | */
10 |
11 | package org.junit.gen5.engine.junit4.samples.junit4;
12 |
13 | import org.junit.Assert;
14 | import org.junit.experimental.theories.Theories;
15 | import org.junit.experimental.theories.Theory;
16 | import org.junit.runner.RunWith;
17 |
18 | @RunWith(Theories.class)
19 | public class SingleFailingTheoryTestCase {
20 |
21 | @Theory
22 | public void theory() {
23 | Assert.fail("this theory should fail");
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/junit5-api/src/main/java/org/junit/gen5/api/extension/ContainerExtensionContext.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2016 the original author or authors.
3 | *
4 | * All rights reserved. This program and the accompanying materials are
5 | * made available under the terms of the Eclipse Public License v1.0 which
6 | * accompanies this distribution and is available at
7 | *
8 | * http://www.eclipse.org/legal/epl-v10.html
9 | */
10 |
11 | package org.junit.gen5.api.extension;
12 |
13 | import static org.junit.gen5.commons.meta.API.Usage.Experimental;
14 |
15 | import org.junit.gen5.commons.meta.API;
16 |
17 | /**
18 | * {@code ContainerExtensionContext} encapsulates the context in which
19 | * the current container is being executed.
20 | *
21 | * @since 5.0
22 | */
23 | @API(Experimental)
24 | public interface ContainerExtensionContext extends ExtensionContext {
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/junit-tests/src/test/java/org/junit/gen5/engine/junit4/samples/junit4/JUnit4SuiteOfSuiteWithJUnit4TestCaseWithAssumptionFailureInBeforeClass.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2016 the original author or authors.
3 | *
4 | * All rights reserved. This program and the accompanying materials are
5 | * made available under the terms of the Eclipse Public License v1.0 which
6 | * accompanies this distribution and is available at
7 | *
8 | * http://www.eclipse.org/legal/epl-v10.html
9 | */
10 |
11 | package org.junit.gen5.engine.junit4.samples.junit4;
12 |
13 | import org.junit.runner.RunWith;
14 | import org.junit.runners.Suite;
15 | import org.junit.runners.Suite.SuiteClasses;
16 |
17 | @RunWith(Suite.class)
18 | @SuiteClasses(JUnit4SuiteWithJUnit4TestCaseWithAssumptionFailureInBeforeClass.class)
19 | public class JUnit4SuiteOfSuiteWithJUnit4TestCaseWithAssumptionFailureInBeforeClass {
20 | }
21 |
--------------------------------------------------------------------------------
/junit4-engine/src/main/java/org/junit/gen5/engine/junit4/discovery/ClassSelectorResolver.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2016 the original author or authors.
3 | *
4 | * All rights reserved. This program and the accompanying materials are
5 | * made available under the terms of the Eclipse Public License v1.0 which
6 | * accompanies this distribution and is available at
7 | *
8 | * http://www.eclipse.org/legal/epl-v10.html
9 | */
10 |
11 | package org.junit.gen5.engine.junit4.discovery;
12 |
13 | import org.junit.gen5.engine.discovery.ClassSelector;
14 |
15 | class ClassSelectorResolver extends DiscoverySelectorResolver {
16 |
17 | ClassSelectorResolver() {
18 | super(ClassSelector.class);
19 | }
20 |
21 | @Override
22 | void resolve(ClassSelector selector, TestClassCollector collector) {
23 | collector.addCompletely(selector.getTestClass());
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/junit-engine-api/src/main/java/org/junit/gen5/engine/TestEngine.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2016 the original author or authors.
3 | *
4 | * All rights reserved. This program and the accompanying materials are
5 | * made available under the terms of the Eclipse Public License v1.0 which
6 | * accompanies this distribution and is available at
7 | *
8 | * http://www.eclipse.org/legal/epl-v10.html
9 | */
10 |
11 | package org.junit.gen5.engine;
12 |
13 | import static org.junit.gen5.commons.meta.API.Usage.Experimental;
14 |
15 | import org.junit.gen5.commons.meta.API;
16 |
17 | /**
18 | * @since 5.0
19 | */
20 | @API(Experimental)
21 | public interface TestEngine {
22 |
23 | default String getId() {
24 | return getClass().getCanonicalName();
25 | }
26 |
27 | TestDescriptor discover(EngineDiscoveryRequest discoveryRequest);
28 |
29 | void execute(ExecutionRequest request);
30 | }
31 |
--------------------------------------------------------------------------------
/junit-tests/src/test/java/org/junit/gen5/engine/junit4/samples/junit4/EnclosedJUnit4TestCase.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2016 the original author or authors.
3 | *
4 | * All rights reserved. This program and the accompanying materials are
5 | * made available under the terms of the Eclipse Public License v1.0 which
6 | * accompanies this distribution and is available at
7 | *
8 | * http://www.eclipse.org/legal/epl-v10.html
9 | */
10 |
11 | package org.junit.gen5.engine.junit4.samples.junit4;
12 |
13 | import static org.junit.Assert.fail;
14 |
15 | import org.junit.Test;
16 | import org.junit.experimental.runners.Enclosed;
17 | import org.junit.runner.RunWith;
18 |
19 | @RunWith(Enclosed.class)
20 | public class EnclosedJUnit4TestCase {
21 |
22 | public static class NestedClass {
23 |
24 | @Test
25 | public void failingTest() {
26 | fail("this test should fail");
27 | }
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/junit-tests/src/test/java/org/junit/gen5/engine/junit4/samples/junit4/JUnit4TestCaseWithErrorInBeforeClass.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2016 the original author or authors.
3 | *
4 | * All rights reserved. This program and the accompanying materials are
5 | * made available under the terms of the Eclipse Public License v1.0 which
6 | * accompanies this distribution and is available at
7 | *
8 | * http://www.eclipse.org/legal/epl-v10.html
9 | */
10 |
11 | package org.junit.gen5.engine.junit4.samples.junit4;
12 |
13 | import static org.junit.Assert.fail;
14 |
15 | import org.junit.BeforeClass;
16 | import org.junit.Test;
17 |
18 | public class JUnit4TestCaseWithErrorInBeforeClass {
19 |
20 | @BeforeClass
21 | public static void failingBeforeClass() {
22 | fail("something went wrong");
23 | }
24 |
25 | @Test
26 | public void test() {
27 | fail("this should never be called");
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/junit-tests/src/test/java/org/junit/gen5/engine/junit5/descriptor/subpackage/ClassWithStaticInnerTestCases.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2016 the original author or authors.
3 | *
4 | * All rights reserved. This program and the accompanying materials are
5 | * made available under the terms of the Eclipse Public License v1.0 which
6 | * accompanies this distribution and is available at
7 | *
8 | * http://www.eclipse.org/legal/epl-v10.html
9 | */
10 |
11 | package org.junit.gen5.engine.junit5.descriptor.subpackage;
12 |
13 | import org.junit.gen5.api.Test;
14 |
15 | /**
16 | * @since 5.0
17 | */
18 | public class ClassWithStaticInnerTestCases {
19 |
20 | static class ShouldBeDiscovered {
21 |
22 | @Test
23 | void test1() {
24 | }
25 | }
26 |
27 | @SuppressWarnings("unused")
28 | private static class ShouldNotBeDiscovered {
29 |
30 | @Test
31 | void test2() {
32 | }
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/junit5-engine/src/main/java/org/junit/gen5/engine/junit5/discovery/JUnit5Class.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2016 the original author or authors.
3 | *
4 | * All rights reserved. This program and the accompanying materials are
5 | * made available under the terms of the Eclipse Public License v1.0 which
6 | * accompanies this distribution and is available at
7 | *
8 | * http://www.eclipse.org/legal/epl-v10.html
9 | */
10 |
11 | package org.junit.gen5.engine.junit5.discovery;
12 |
13 | class JUnit5Class extends JUnit5Testable {
14 |
15 | private final Class> javaClass;
16 |
17 | JUnit5Class(String uniqueId, Class> javaClass) {
18 | super(uniqueId);
19 | this.javaClass = javaClass;
20 | }
21 |
22 | Class> getJavaClass() {
23 | return this.javaClass;
24 | }
25 |
26 | @Override
27 | void accept(Visitor visitor) {
28 | visitor.visitClass(getUniqueId(), this.javaClass);
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/documentation/src/test/java/example/timing/TimingExtensionTests.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2016 the original author or authors.
3 | *
4 | * All rights reserved. This program and the accompanying materials are
5 | * made available under the terms of the Eclipse Public License v1.0 which
6 | * accompanies this distribution and is available at
7 | *
8 | * http://www.eclipse.org/legal/epl-v10.html
9 | */
10 |
11 | package example.timing;
12 |
13 | import org.junit.gen5.api.Test;
14 | import org.junit.gen5.api.extension.ExtendWith;
15 |
16 | /**
17 | * Tests that demonstrate the example {@link TimingExtension}.
18 | *
19 | * @since 5.0
20 | */
21 | @ExtendWith(TimingExtension.class)
22 | class TimingExtensionTests {
23 |
24 | @Test
25 | void sleep20ms() throws Exception {
26 | Thread.sleep(20);
27 | }
28 |
29 | @Test
30 | void sleep50ms() throws Exception {
31 | Thread.sleep(50);
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/junit-tests/src/test/java/org/junit/gen5/engine/junit4/samples/junit3/JUnit3SuiteWithSingleTestCaseWithSingleTestWhichFails.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2016 the original author or authors.
3 | *
4 | * All rights reserved. This program and the accompanying materials are
5 | * made available under the terms of the Eclipse Public License v1.0 which
6 | * accompanies this distribution and is available at
7 | *
8 | * http://www.eclipse.org/legal/epl-v10.html
9 | */
10 |
11 | package org.junit.gen5.engine.junit4.samples.junit3;
12 |
13 | import junit.framework.TestCase;
14 | import junit.framework.TestSuite;
15 |
16 | public class JUnit3SuiteWithSingleTestCaseWithSingleTestWhichFails extends TestCase {
17 |
18 | public static junit.framework.Test suite() {
19 | TestSuite suite = new TestSuite();
20 | suite.addTestSuite(PlainJUnit3TestCaseWithSingleTestWhichFails.class);
21 | return suite;
22 | }
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/junit-engine-api/src/main/java/org/junit/gen5/engine/support/hierarchical/EngineExecutionContext.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2016 the original author or authors.
3 | *
4 | * All rights reserved. This program and the accompanying materials are
5 | * made available under the terms of the Eclipse Public License v1.0 which
6 | * accompanies this distribution and is available at
7 | *
8 | * http://www.eclipse.org/legal/epl-v10.html
9 | */
10 |
11 | package org.junit.gen5.engine.support.hierarchical;
12 |
13 | import static org.junit.gen5.commons.meta.API.Usage.Experimental;
14 |
15 | import org.junit.gen5.commons.meta.API;
16 |
17 | /**
18 | * Marker interface for an execution context used by a concrete implementation
19 | * of {@link HierarchicalTestEngine} and its collaborators.
20 | *
21 | * @since 5.0
22 | * @see HierarchicalTestEngine
23 | */
24 | @API(Experimental)
25 | public interface EngineExecutionContext {
26 | }
27 |
--------------------------------------------------------------------------------
/documentation/src/test/java/example/exception/IgnoreIOExceptionTests.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2016 the original author or authors.
3 | *
4 | * All rights reserved. This program and the accompanying materials are
5 | * made available under the terms of the Eclipse Public License v1.0 which
6 | * accompanies this distribution and is available at
7 | *
8 | * http://www.eclipse.org/legal/epl-v10.html
9 | */
10 |
11 | package example.exception;
12 |
13 | import java.io.IOException;
14 |
15 | import extensions.ExpectToFail;
16 |
17 | import org.junit.gen5.api.Test;
18 | import org.junit.gen5.api.extension.ExtendWith;
19 |
20 | @ExtendWith(IgnoreIOExceptionExtension.class)
21 | class IgnoreIOExceptionTests {
22 |
23 | @Test
24 | void shouldSucceed() throws IOException {
25 | throw new IOException("any");
26 | }
27 |
28 | @Test
29 | @ExpectToFail
30 | void shouldFail() {
31 | throw new RuntimeException("any");
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/junit-tests/src/test/java/org/junit/gen5/engine/junit4/samples/junit4/JUnit4SuiteWithJUnit3SuiteWithSingleTestCase.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2016 the original author or authors.
3 | *
4 | * All rights reserved. This program and the accompanying materials are
5 | * made available under the terms of the Eclipse Public License v1.0 which
6 | * accompanies this distribution and is available at
7 | *
8 | * http://www.eclipse.org/legal/epl-v10.html
9 | */
10 |
11 | package org.junit.gen5.engine.junit4.samples.junit4;
12 |
13 | import org.junit.gen5.engine.junit4.samples.junit3.JUnit3SuiteWithSingleTestCaseWithSingleTestWhichFails;
14 | import org.junit.runner.RunWith;
15 | import org.junit.runners.Suite;
16 | import org.junit.runners.Suite.SuiteClasses;
17 |
18 | @RunWith(Suite.class)
19 | @SuiteClasses(JUnit3SuiteWithSingleTestCaseWithSingleTestWhichFails.class)
20 | public class JUnit4SuiteWithJUnit3SuiteWithSingleTestCase {
21 | }
22 |
--------------------------------------------------------------------------------
/junit5-api/src/main/java/org/junit/gen5/api/extension/MethodInvocationContext.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2016 the original author or authors.
3 | *
4 | * All rights reserved. This program and the accompanying materials are
5 | * made available under the terms of the Eclipse Public License v1.0 which
6 | * accompanies this distribution and is available at
7 | *
8 | * http://www.eclipse.org/legal/epl-v10.html
9 | */
10 |
11 | package org.junit.gen5.api.extension;
12 |
13 | import static org.junit.gen5.commons.meta.API.Usage.Experimental;
14 |
15 | import java.lang.reflect.Method;
16 |
17 | import org.junit.gen5.commons.meta.API;
18 |
19 | /**
20 | * {@code MethodInvocationContext} encapsulates the context in which
21 | * a method is to be invoked.
22 | *
23 | * @since 5.0
24 | */
25 | @API(Experimental)
26 | public interface MethodInvocationContext {
27 |
28 | Object getInstance();
29 |
30 | Method getMethod();
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/junit4-engine/src/main/java/org/junit/gen5/engine/junit4/discovery/IsPotentialJUnit4TestMethod.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2016 the original author or authors.
3 | *
4 | * All rights reserved. This program and the accompanying materials are
5 | * made available under the terms of the Eclipse Public License v1.0 which
6 | * accompanies this distribution and is available at
7 | *
8 | * http://www.eclipse.org/legal/epl-v10.html
9 | */
10 |
11 | package org.junit.gen5.engine.junit4.discovery;
12 |
13 | import java.lang.reflect.Method;
14 | import java.util.function.Predicate;
15 |
16 | import org.junit.Test;
17 |
18 | /**
19 | * @since 5.0
20 | */
21 | class IsPotentialJUnit4TestMethod implements Predicate {
22 |
23 | @Override
24 | public boolean test(Method method) {
25 | // Don't use AnnotationUtils.hasAnnotation since JUnit 4 does not support
26 | // meta-annotations
27 | return method.isAnnotationPresent(Test.class);
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/junit5-api/src/main/java/org/junit/gen5/api/extension/Extension.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2016 the original author or authors.
3 | *
4 | * All rights reserved. This program and the accompanying materials are
5 | * made available under the terms of the Eclipse Public License v1.0 which
6 | * accompanies this distribution and is available at
7 | *
8 | * http://www.eclipse.org/legal/epl-v10.html
9 | */
10 |
11 | package org.junit.gen5.api.extension;
12 |
13 | import static org.junit.gen5.commons.meta.API.Usage.Experimental;
14 |
15 | import org.junit.gen5.commons.meta.API;
16 |
17 | /**
18 | * Marker interface for all extensions.
19 | *
20 | *