-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Let Testable annotation target any element type
Prior to this commit the usage of `@Testable` was restricted to declarations of types, methods, and fields. As custom test engines may use different element types as their "testable constructs", this restriction is lifted in backward and future-compatible manner. By dropping the `@Target` annotation, the default behaviour as defined by the Java Language Specification applies: If an annotation of type java.lang.annotation.Target is not present on the declaration of an annotation type T, then T is applicable in all declaration contexts except type parameter declarations, and in no type contexts. https://docs.oracle.com/javase/specs/jls/se8/html/jls-9.html#jls-9.6.4.1 Closes #2391
- Loading branch information
Showing
3 changed files
with
55 additions
and
4 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
48 changes: 48 additions & 0 deletions
48
junit-jupiter-engine/src/test/java/org/junit/jupiter/engine/TestableAnnotationTests.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,48 @@ | ||
/* | ||
* Copyright 2015-2020 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 v2.0 which | ||
* accompanies this distribution and is available at | ||
* | ||
* https://www.eclipse.org/legal/epl-v20.html | ||
*/ | ||
|
||
package org.junit.jupiter.engine; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.platform.commons.annotation.Testable; | ||
|
||
/** | ||
* Integration test that verifies that the testable annotation may be | ||
* attached to any element type. | ||
* | ||
* @since 5.7 | ||
*/ | ||
class TestableAnnotationTests { | ||
|
||
@Test | ||
void testAndRepeatedTest() { | ||
assertNotNull(new TestableEverywhere().toString()); | ||
} | ||
|
||
@Testable | ||
static class TestableEverywhere { | ||
|
||
@Testable | ||
final int field = 0; | ||
|
||
@Testable | ||
TestableEverywhere() { | ||
} | ||
|
||
@Testable | ||
void test(@Testable int parameter) { | ||
@Testable | ||
var var = "var"; | ||
} | ||
} | ||
|
||
} |
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