Last active
June 26, 2020 06:47
-
-
Save ptrthomas/b0f81875e30390e7c8c097b9a8e91b4e to your computer and use it in GitHub Desktop.
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
Feature: | |
Scenario: listen to system out and stop after 5 pings | |
* def count = 0 | |
* def listener = | |
""" | |
function(line) { | |
var temp = karate.get('count'); | |
if (line.contains('bytes from')) { | |
temp = temp + 1; | |
karate.set('count', temp); | |
karate.log('count is', temp); | |
} | |
if (temp == 5) { | |
var proc = karate.get('proc'); | |
karate.signal(proc.buffer); | |
} | |
} | |
""" | |
* def proc = karate.fork({ args: ['ping', 'google.com'], listener: listener }) | |
* def output = karate.listen(10000) | |
* print 'console output:', output | |
Scenario: java cli | |
* def proc = karate.fork('java -version') | |
* proc.waitSync() | |
* match proc.getBuffer() == '#regex java version (.+[\\r\\n])+' | |
* assert proc.getExitCode() == 0 | |
Scenario: java fail | |
* def proc = karate.fork('java -foo') | |
* proc.waitSync() | |
* match proc.getBuffer() contains 'Unrecognized option: -foo' | |
* assert proc.getExitCode() == 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment