Mismatch Pinpoint Single Line Text
When comparing strings, WebTau highlights a specific point of failure: Groovy def output = "hallo world" output.should == "hello world" X failed expecting [value] to equal "hello world": actual: "hallo world" <java.lang.String> expected: "hello world" <java.lang.String> ^ (0ms) Check matchers/import-and-dependencies Import And Dependencies for prerequisites. Java String output = "hallo world"; actual(output).should(equal("hello world")); X failed expecting [value] to equal "hello world": actual: "hallo world" <java.lang.String> expected: "hello world" <java.lang.String> ^ (0ms) Check matchers/import-and-dependencies Import And Dependencies for prerequisites.
Mismatch Pinpoint Multi Line Text
In case of a multiline text, WebTau highlights a first mismatched line: Groovy String output = buildOutput() output.should == "line one\nline 2" X failed expecting [value] to equal ________ line one line 2 ________: different number of lines: actual: 3 expected: 2 first mismatch at line idx 1: actual: "line two" expected: "line 2" ^ (0ms) __________ line one **line two** line three __________ Java String output = buildOutput(); actual(output).should(equal("line one\nline 2")); X failed expecting [value] to equal ________ line one line 2 ________: different number of lines: actual: 3 expected: 2 first mismatch at line idx 1: actual: "line two" expected: "line 2" ^ (0ms) __________ line one **line two** line three __________
WebTau automatically checks line ending, e.g. presence of \r and will notify if there is a difference. X failed expecting text to equal _________________ hello world world hello again _________________: different line endings: actual: contains \r expected: doesn't contain \r (1ms) **_________________** hello world world hello again **_________________**
Different Number Of Empty Lines
WebTau separately checks extra empty lines to help with missing/extra \n : Groovy String output = buildOutput() output.should == "line one\nline two\nline three\n" X failed expecting [value] to equal __________ line one line two line three __________: different number of lines: actual: 3 expected: 4 different number of empty lines at the end actual: 0 expected: 1 (0ms) **__________** line one line two line three **__________** Java String output = buildOutput(); actual(output).should(equal("line one\nline two\nline three\n")); X failed expecting [value] to equal __________ line one line two line three __________: different number of lines: actual: 3 expected: 4 different number of empty lines at the end actual: 0 expected: 1 (0ms) **__________** line one line two line three **__________**
Use contains matcher to check a presence of a substring: Groovy String output = buildOutput() output.should contain("four") X failed expecting [value] to contain "four": no match found (0ms) **__________** line one line two line three **__________** Java String output = buildOutput(); actual(output).should(contain("four")); X failed expecting [value] to contain "four": no match found (0ms) **__________** line one line two line three **__________**
Use equal matcher to match against a regular expression: Groovy String output = 'final price: $8998' output.should == ~/final price: \$\d+/ . [value] equals ~/final price: \$\d+/ (0ms) Java String output = "final price: $8998"; actual(output).should(equal(Pattern.compile("final price: \\$\\d+"))); . [value] equals ~/final price: \$\d+/ (0ms)