-
-
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.
added an example for how a custom dsl can be approximated
and for answering whenever anyone asks for creating custom keywords or step definitions etc also some doc edits, just realized that the foo.bar = baz notation can be used in place of the set keyword in most cases, even for dynamic key values like foo[bar] = baz this actually brings down the size of the worlds smallest micro service even more some code cleanup done for the call keyword as well
- Loading branch information
Showing
13 changed files
with
70 additions
and
86 deletions.
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
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,22 @@ | ||
package demo.dsl; | ||
|
||
import com.intuit.karate.KarateOptions; | ||
import com.intuit.karate.junit4.Karate; | ||
import org.junit.BeforeClass; | ||
import org.junit.runner.RunWith; | ||
|
||
/** | ||
* | ||
* @author pthomas3 | ||
*/ | ||
@RunWith(Karate.class) | ||
@KarateOptions(features = "classpath:demo/dsl/dsl.feature") | ||
public class DslRunner { | ||
|
||
@BeforeClass | ||
public static void beforeClass() { | ||
// skip 'callSingle' in karate-config.js | ||
System.setProperty("karate.env", "mock"); | ||
} | ||
|
||
} |
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 @@ | ||
@ignore | ||
Feature: | ||
|
||
Scenario: | ||
# in-line js function | ||
* def quack = function(){ karate.log('quack!') } | ||
|
||
# js function from file | ||
* def greet = read('greet.js') | ||
|
||
# feature from file | ||
* def login = read('login.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,14 @@ | ||
Feature: how you can define custom keywords | ||
|
||
Background: | ||
* call read('common.feature') | ||
|
||
Scenario: re-using code in a readable style | ||
# invoke js function | ||
* quack() | ||
|
||
# call js function | ||
* call greet 'John' | ||
|
||
# call feature | ||
* call login { name: 'John', type: 'admin' } |
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,3 @@ | ||
function fn(name) { | ||
karate.log('hello ' + name + '!'); | ||
} |
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 @@ | ||
@ignore | ||
Feature: re-usable feature | ||
|
||
Scenario: | ||
# note that __arg is also available | ||
* print 'logged in user name:', name | ||
* print 'logged in user type:', type |
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 was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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