-
Notifications
You must be signed in to change notification settings - Fork 1k
Support getting dependencies info for a test #2839
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
Merged
Merged
Changes from all commits
Commits
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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
44 changes: 44 additions & 0 deletions
44
testng-core/src/test/java/test/dependent/issue893/DependencyTrackingListener.java
This file contains hidden or 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,44 @@ | ||
| package test.dependent.issue893; | ||
|
|
||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
| import java.util.Set; | ||
| import java.util.stream.Collectors; | ||
| import org.testng.ITestContext; | ||
| import org.testng.ITestListener; | ||
| import org.testng.ITestNGMethod; | ||
| import org.testng.ITestResult; | ||
| import org.testng.collections.Sets; | ||
|
|
||
| public class DependencyTrackingListener implements ITestListener { | ||
| private final Map<String, Set<String>> downstreamDependencies = new HashMap<>(); | ||
| private final Map<String, Set<String>> upstreamDependencies = new HashMap<>(); | ||
|
|
||
| @Override | ||
| public void onTestStart(ITestResult result) { | ||
| ITestContext context = result.getTestContext(); | ||
| for (ITestNGMethod method : context.getAllTestMethods()) { | ||
| String key = method.getQualifiedName(); | ||
| downstreamDependencies | ||
| .computeIfAbsent(key, k -> Sets.newHashSet()) | ||
| .addAll( | ||
| method.downstreamDependencies().stream() | ||
| .map(ITestNGMethod::getQualifiedName) | ||
| .collect(Collectors.toList())); | ||
| upstreamDependencies | ||
| .computeIfAbsent(key, k -> Sets.newHashSet()) | ||
| .addAll( | ||
| method.upstreamDependencies().stream() | ||
| .map(ITestNGMethod::getQualifiedName) | ||
| .collect(Collectors.toList())); | ||
| } | ||
| } | ||
|
|
||
| public Map<String, Set<String>> getUpstreamDependencies() { | ||
| return upstreamDependencies; | ||
| } | ||
|
|
||
| public Map<String, Set<String>> getDownstreamDependencies() { | ||
| return downstreamDependencies; | ||
| } | ||
| } |
17 changes: 17 additions & 0 deletions
17
testng-core/src/test/java/test/dependent/issue893/MultiLevelDependenciesTestClassSample.java
This file contains hidden or 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,17 @@ | ||
| package test.dependent.issue893; | ||
|
|
||
| import org.testng.annotations.Test; | ||
|
|
||
| public class MultiLevelDependenciesTestClassSample { | ||
| @Test | ||
| public void grandFather() {} | ||
|
|
||
| @Test(dependsOnMethods = "grandFather") | ||
| public void father() {} | ||
|
|
||
| @Test(dependsOnMethods = "grandFather") | ||
| public void mother() {} | ||
|
|
||
| @Test(dependsOnMethods = {"father", "mother"}) | ||
| public void child() {} | ||
| } |
15 changes: 15 additions & 0 deletions
15
testng-core/src/test/java/test/dependent/issue893/TestClassSample.java
This file contains hidden or 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,15 @@ | ||
| package test.dependent.issue893; | ||
|
|
||
| import org.testng.annotations.Test; | ||
|
|
||
| public class TestClassSample { | ||
|
|
||
| @Test | ||
| public void independentTest() {} | ||
|
|
||
| @Test(dependsOnMethods = "independentTest") | ||
| public void dependentTest() {} | ||
|
|
||
| @Test(dependsOnMethods = "independentTest") | ||
| public void anotherDependentTest() {} | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.