Should

WebTau provides two ways to assert values: should and waitTo . They work for business logic testing, HTTP, Browser, and other layers. Methods accept a matcher as a second parameter: WebTau provides console output for all the matching it does, regardless of whether it fails or passes. Use should to assert a value using a matcher. One of the most common matchers is equal . In WebTau equal is a universal matcher that you will learn about matchers/universal-compare later. Groovy def errorMessage = generateErrorMessage() errorMessage.should == "insufficient disk space" // string and string equality comparison . [value] equals "insufficient disk space" (0ms) Note: Groovy has a shortcut for equal matcher. Check matchers/import-and-dependencies Import And Dependencies for prerequisites. Java String errorMessage = generateErrorMessage(); actual(errorMessage).should(equal("insufficient disk space")); // string and string equality comparison . [value] equals "insufficient disk space" (0ms) Check matchers/import-and-dependencies Import And Dependencies for prerequisites. Use shouldBe alias to make a better flow with matchers like greaterThan : Groovy def numberAsText = "200" numberAsText.shouldBe > 150 // text and number relative comparison . [value] greater than 150 (2ms) Java String numberAsText = "200"; actual(numberAsText).shouldBe(greaterThan(150)); // text and number relative comparison . [value] greater than 150 (2ms)

WaitTo

Use waitTo to wait for a value to eventually match a matcher. Groovy actual(liveValue(this::consumeMessage)).waitTo == "message we wait for" > waiting for [value] to equal "message we wait for" . [value] equals "message we wait for" (201ms) Java actual(liveValue(this::consumeMessage)).waitTo(equal("message we wait for")); > waiting for [value] to equal "message we wait for" . [value] equals "message we wait for" (201ms) Use waitToBe alias to make a better flow with matchers like greaterThan : Groovy actual(liveValue(this::countRecords)).waitToBe >= 5 > waiting for [value] to be greater than or equal to 5 . [value] greater than or equal 5 (401ms) Java actual(liveValue(this::countRecords)).waitToBe(greaterThanOrEqual(5)); > waiting for [value] to be greater than or equal to 5 . [value] greater than or equal 5 (401ms)

Negative Matching

Both should and waitTo have negative forms: Groovy def errorMessage = generateErrorMessage() errorMessage.shouldNot == "completed" . [value] doesn't equal "completed" (0ms) Java String errorMessage = generateErrorMessage(); actual(errorMessage).shouldNot(equal("completed")); . [value] doesn't equal "completed" (0ms) Groovy actual(liveValue(this::consumeMessage)).waitToNot == "duplicate" > waiting for [value] to not equal "duplicate" . [value] doesn't equal "duplicate" (1ms) Java actual(liveValue(this::consumeMessage)).waitToNot(equal("duplicate")); > waiting for [value] to not equal "duplicate" . [value] doesn't equal "duplicate" (1ms)

Failure Output

Above you saw how WebTau outputs matched information. In case of failed assertion WebTau outputs additional information about the actual value. Groovy values.should == [ 1, "teasing", [key1: "hello", key2: "work"]] X failed expecting [value] to equal [1, "teasing", {"key1": "hello", "key2": "work"}]: [value][1]: actual: "testing" <java.lang.String> expected: "teasing" <java.lang.String> ^ [value][2].key2: actual: "world" <java.lang.String> expected: "work" <java.lang.String> ^ (1ms) [1, **"testing"**, {"key1": "hello", "key2": **"world"**}] Java actual(values).should(equal(Arrays.asList( 1, "teasing", map("key1", "hello", "key2", "work")))); X failed expecting [value] to equal [1, "teasing", {"key1": "hello", "key2": "work"}]: [value][1]: actual: "testing" <java.lang.String> expected: "teasing" <java.lang.String> ^ [value][2].key2: actual: "world" <java.lang.String> expected: "work" <java.lang.String> ^ (1ms) [1, **"testing"**, {"key1": "hello", "key2": **"world"**}]