-
Notifications
You must be signed in to change notification settings - Fork 12
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
Adds package annotation for affected tests #220
Closed
+401
−33
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
e818a53
[WiP] Adds package annotation for affected tests
lordofthejars 02554bb
Updates pom.xml
lordofthejars 971cf8d
Minor changes and updates documentation
lordofthejars 34859ea
Code review changes and creation of ftest
lordofthejars 074b51a
Resolves merge conflicts
lordofthejars File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<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/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<artifactId>smart-testing-parent</artifactId> | ||
<groupId>org.arquillian.smart.testing</groupId> | ||
<version>0.0.4-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>api</artifactId> | ||
|
||
</project> |
42 changes: 42 additions & 0 deletions
42
api/src/main/java/org/arquillian/smart/testing/strategies/affected/ComponentUnderTest.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,42 @@ | ||
package org.arquillian.smart.testing.strategies.affected; | ||
|
||
import java.lang.annotation.Documented; | ||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Repeatable; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
/** | ||
* Annotation used to set which production classes are tested in current test. | ||
* By default it appends all classes defined in all attributes. | ||
* | ||
* If none of the attributes are set, then all production classes with same package as test and its subpackages are added. | ||
*/ | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target(ElementType.TYPE) | ||
@Repeatable(ComponentsUnderTest.class) | ||
@Documented | ||
public @interface ComponentUnderTest { | ||
|
||
/** | ||
* Packages of classes that needs to be added as tested classes in current test. You can set the package name "org.superbiz" which means only classes defined in this package, | ||
* or ending with start (*) operator "org.superbiz.*" which means all classes of current package and its subpackages. | ||
* @return Packages containing Java classes. | ||
*/ | ||
String[] packages() default {}; | ||
|
||
/** | ||
* Packages of classes that needs to be added as tested classes in current test. It is used Class to get the package. | ||
* Notice that in this case subpackages are not scanned. | ||
* @return Packages containing Java classes. | ||
*/ | ||
Class[] packagesOf() default {}; | ||
|
||
/** | ||
* Classes to be added as tested classes in current test. | ||
* @return Classes | ||
*/ | ||
Class[] classes() default {}; | ||
|
||
} |
14 changes: 14 additions & 0 deletions
14
api/src/main/java/org/arquillian/smart/testing/strategies/affected/ComponentsUnderTest.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,14 @@ | ||
package org.arquillian.smart.testing.strategies.affected; | ||
|
||
import java.lang.annotation.Documented; | ||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target(ElementType.TYPE) | ||
@Documented | ||
public @interface ComponentsUnderTest { | ||
ComponentUnderTest[] value(); | ||
} |
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
50 changes: 50 additions & 0 deletions
50
...g/ftest/affected/LocalChangesAffectedAnnotationTestsSelectionExecutionFunctionalTest.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,50 @@ | ||
package org.arquillian.smart.testing.ftest.affected; | ||
|
||
import java.util.Collection; | ||
import org.arquillian.smart.testing.ftest.testbed.project.Project; | ||
import org.arquillian.smart.testing.ftest.testbed.project.TestResults; | ||
import org.arquillian.smart.testing.ftest.testbed.testresults.TestResult; | ||
import org.arquillian.smart.testing.mvn.ext.dependencies.ExtensionVersion; | ||
import org.arquillian.smart.testing.rules.TestBed; | ||
import org.arquillian.smart.testing.rules.git.GitClone; | ||
import org.junit.ClassRule; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
|
||
import static org.arquillian.smart.testing.ftest.testbed.TestRepository.testRepository; | ||
import static org.arquillian.smart.testing.ftest.testbed.configuration.Mode.SELECTING; | ||
import static org.arquillian.smart.testing.ftest.testbed.configuration.Strategy.AFFECTED; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
public class LocalChangesAffectedAnnotationTestsSelectionExecutionFunctionalTest { | ||
|
||
@ClassRule | ||
public static final GitClone GIT_CLONE = new GitClone(testRepository()); | ||
|
||
@Rule | ||
public final TestBed testBed = new TestBed(GIT_CLONE); | ||
|
||
@Test | ||
public void should_only_execute_tests_with_affected_changes_annotated() throws Exception { | ||
// given | ||
final Project project = testBed.getProject(); | ||
|
||
project.configureSmartTesting() | ||
.executionOrder(AFFECTED) | ||
.inMode(SELECTING) | ||
.enable(); | ||
|
||
final Collection<TestResult> expectedTestResults = project | ||
.applyAsLocalChanges("Uses annotation to detect affected classes"); | ||
|
||
// when | ||
final TestResults actualTestResults = project.build("config/impl-base") | ||
.options().withSystemProperties("smart.testing.version", ExtensionVersion.version().toString()) | ||
.configure() | ||
.run(); | ||
|
||
// then | ||
assertThat(actualTestResults.accumulatedPerTestClass()).containsAll(expectedTestResults).hasSameSizeAs(expectedTestResults); | ||
} | ||
|
||
} |
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
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Really light project for scanning classpath. I think we can use more and more features it offers.