-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2518 from dvargas46/develop
reamining features fix #2432
- Loading branch information
Showing
5 changed files
with
69 additions
and
1 deletion.
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
44 changes: 44 additions & 0 deletions
44
karate-core/src/test/java/com/intuit/karate/core/features/RemainingFeaturesTest.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,44 @@ | ||
package com.intuit.karate.core.features; | ||
|
||
import com.intuit.karate.Results; | ||
import com.intuit.karate.Runner; | ||
import com.intuit.karate.Suite; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
public class RemainingFeaturesTest { | ||
|
||
private static Suite suite; | ||
|
||
@Test | ||
void testRemainingFeaturesSingleThread() { | ||
verifyRemainingFeaturesWithThreads(1); | ||
} | ||
|
||
@Test | ||
void testRemainingFeaturesParallel() { | ||
verifyRemainingFeaturesWithThreads(2); | ||
} | ||
|
||
/** | ||
* Hooks into the current suite to return the remaining features within the test | ||
* @return Remaining features count | ||
*/ | ||
public static long remainingFeatures() { | ||
return suite.getFeaturesRemaining(); | ||
} | ||
|
||
private void verifyRemainingFeaturesWithThreads(int threads) { | ||
Runner.Builder<?> builder = Runner.builder() | ||
.path("classpath:com/intuit/karate/core/features") | ||
.configDir("classpath:com/intuit/karate/core/features") | ||
.threads(threads); | ||
builder.resolveAll(); | ||
suite = new Suite(builder); | ||
suite.run(); | ||
Results results = suite.buildResults(); | ||
assertEquals(0, results.getFailCount(), results.getErrorMessages()); | ||
} | ||
|
||
} |
7 changes: 7 additions & 0 deletions
7
karate-core/src/test/java/com/intuit/karate/core/features/feature1.feature
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,7 @@ | ||
Feature: | ||
|
||
Scenario: feature test 1 | ||
* def numOfFeaturesLeft = remainingFeatures() | ||
* print 'Features left (including this one):', numOfFeaturesLeft | ||
# this is the first feature that runs, so there should be more than 1 feature running | ||
* assert numOfFeaturesLeft > 1 |
7 changes: 7 additions & 0 deletions
7
karate-core/src/test/java/com/intuit/karate/core/features/feature2.feature
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,7 @@ | ||
Feature: | ||
|
||
Scenario: feature test 2 | ||
* def numOfFeaturesLeft = remainingFeatures() | ||
* print 'Features left (including this one):', numOfFeaturesLeft | ||
# there should always be at least 1 feature left, even if it's the current feature running | ||
* assert numOfFeaturesLeft >= 1 |
8 changes: 8 additions & 0 deletions
8
karate-core/src/test/java/com/intuit/karate/core/features/karate-config.js
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,8 @@ | ||
function karateConfig() { | ||
const config = {} | ||
|
||
const RemainingFeaturesTest = Java.type('com.intuit.karate.core.features.RemainingFeaturesTest') | ||
config.remainingFeatures = RemainingFeaturesTest.remainingFeatures | ||
|
||
return config | ||
} |