Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed scanning of static inner classes, tests included.
------------------------------------------------------------------------ On behalf of the community, the JUnit Lambda Team thanks Klarna AB (http://www.klarna.com) for supporting the JUnit crowdfunding campaign! ------------------------------------------------------------------------
- Loading branch information
Showing
4 changed files
with
71 additions
and
5 deletions.
There are no files selected for viewing
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
30 changes: 30 additions & 0 deletions
30
...ava/org/junit/gen5/engine/junit5/descriptor/subpackage/ClassWithStaticInnerTestCases.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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,30 @@ | |||
/* | |||
* Copyright 2015-2016 the original author or authors. | |||
* | |||
* All rights reserved. This program and the accompanying materials are | |||
* made available under the terms of the Eclipse Public License v1.0 which | |||
* accompanies this distribution and is available at | |||
* | |||
* http://www.eclipse.org/legal/epl-v10.html | |||
*/ | |||
|
|||
package org.junit.gen5.engine.junit5.descriptor.subpackage; | |||
|
|||
import org.junit.gen5.api.Test; | |||
|
|||
public class ClassWithStaticInnerTestCases { | |||
|
|||
static class ShouldBeDiscovered { | |||
@Test | |||
void test1() { | |||
|
|||
} | |||
} | |||
|
|||
private static class ShouldNotBeDiscovered { | |||
@Test | |||
void test2() { | |||
|
|||
} | |||
} | |||
} |
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
34 changes: 34 additions & 0 deletions
34
junit5-engine/src/main/java/org/junit/gen5/engine/junit5/discovery/IsScannableTestClass.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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,34 @@ | |||
/* | |||
* Copyright 2015-2016 the original author or authors. | |||
* | |||
* All rights reserved. This program and the accompanying materials are | |||
* made available under the terms of the Eclipse Public License v1.0 which | |||
* accompanies this distribution and is available at | |||
* | |||
* http://www.eclipse.org/legal/epl-v10.html | |||
*/ | |||
|
|||
package org.junit.gen5.engine.junit5.discovery; | |||
|
|||
import java.util.function.Predicate; | |||
|
|||
import org.junit.gen5.commons.util.ReflectionUtils; | |||
|
|||
/** | |||
* Test if a class is a JUnit 5 test class which should be included in package and classpath scanning. | |||
* | |||
* @since 5.0 | |||
*/ | |||
public class IsScannableTestClass implements Predicate<Class<?>> { | |||
|
|||
private static final IsTestClassWithTests isTestClassWithTests = new IsTestClassWithTests(); | |||
|
|||
@Override | |||
public boolean test(Class<?> candidate) { | |||
//please do not collapse into single return | |||
if (ReflectionUtils.isPrivate(candidate)) | |||
return false; | |||
return isTestClassWithTests.test(candidate); | |||
} | |||
|
|||
} |