File tree Expand file tree Collapse file tree 4 files changed +66
-0
lines changed
karate-core/src/test/java/com/intuit/karate/core/features Expand file tree Collapse file tree 4 files changed +66
-0
lines changed Original file line number Diff line number Diff line change
1
+ package com .intuit .karate .core .features ;
2
+
3
+ import com .intuit .karate .Results ;
4
+ import com .intuit .karate .Runner ;
5
+ import com .intuit .karate .Suite ;
6
+ import org .junit .jupiter .api .Test ;
7
+
8
+ import static org .junit .jupiter .api .Assertions .assertEquals ;
9
+
10
+ public class RemainingFeaturesTest {
11
+
12
+ private static Suite suite ;
13
+
14
+ @ Test
15
+ void testRemainingFeaturesSingleThread () {
16
+ verifyRemainingFeaturesWithThreads (1 );
17
+ }
18
+
19
+ @ Test
20
+ void testRemainingFeaturesParallel () {
21
+ verifyRemainingFeaturesWithThreads (2 );
22
+ }
23
+
24
+ /**
25
+ * Hooks into the current suite to return the remaining features within the test
26
+ * @return Remaining features count
27
+ */
28
+ public static long remainingFeatures () {
29
+ return suite .getFeaturesRemaining ();
30
+ }
31
+
32
+ private void verifyRemainingFeaturesWithThreads (int threads ) {
33
+ Runner .Builder <?> builder = Runner .builder ()
34
+ .path ("classpath:com/intuit/karate/core/features" )
35
+ .configDir ("classpath:com/intuit/karate/core/features" )
36
+ .threads (threads );
37
+ builder .resolveAll ();
38
+ suite = new Suite (builder );
39
+ suite .run ();
40
+ Results results = suite .buildResults ();
41
+ assertEquals (0 , results .getFailCount (), results .getErrorMessages ());
42
+ }
43
+
44
+ }
Original file line number Diff line number Diff line change
1
+ Feature:
2
+
3
+ Scenario : feature test 1
4
+ * def numOfFeaturesLeft = remainingFeatures()
5
+ * print 'Features left (including this one):' , numOfFeaturesLeft
6
+ # this is the first feature that runs, so there should be more than 1 feature running
7
+ * assert numOfFeaturesLeft > 1
Original file line number Diff line number Diff line change
1
+ Feature:
2
+
3
+ Scenario : feature test 2
4
+ * def numOfFeaturesLeft = remainingFeatures()
5
+ * print 'Features left (including this one):' , numOfFeaturesLeft
6
+ # there should always be at least 1 feature left, even if it's the current feature running
7
+ * assert numOfFeaturesLeft >= 1
Original file line number Diff line number Diff line change
1
+ function karateConfig ( ) {
2
+ const config = { }
3
+
4
+ const RemainingFeaturesTest = Java . type ( 'com.intuit.karate.core.features.RemainingFeaturesTest' )
5
+ config . remainingFeatures = RemainingFeaturesTest . remainingFeatures
6
+
7
+ return config
8
+ }
You can’t perform that action at this time.
0 commit comments