Skip to content

Commit

Permalink
adding abort example to demo for discussion ref #755
Browse files Browse the repository at this point in the history
  • Loading branch information
ptrthomas committed May 2, 2019
1 parent 8a844ea commit c736f56
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
20 changes: 20 additions & 0 deletions karate-demo/src/test/java/demo/abort/AbortRunner.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package demo.abort;

import com.intuit.karate.junit4.Karate;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;

/**
*
* @author pthomas3
*/
@RunWith(Karate.class)
public class AbortRunner {

@BeforeClass
public static void beforeClass() {
// skip 'callSingle' in karate-config.js
System.setProperty("karate.env", "mock");
}

}
9 changes: 9 additions & 0 deletions karate-demo/src/test/java/demo/abort/abort.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Feature: abort should skip (but not fail) a test

Scenario: you can conditionally exit a test
but please use sparingly

* print 'before'
* eval if (true) karate.abort()
* print 'after'

Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Given def cat =
Then match cat.kittens[*].id == [23, 42]
Then match cat.kittens[*].id contains 23
Then match cat.kittens[*].id contains [42, 23]
Then match cat..name == ['Billie', 'Bob', 'Wild']
Then match each cat.kittens contains { id: '#number' }
Then match each cat.kittens == { id: '#notnull', name: '#regex [A-Z][a-z]+' }

Expand Down

0 comments on commit c736f56

Please sign in to comment.