Cross Types Comparison

In WebTau you can compare strings, dates, arrays, strings and numbers, dates and strings, arrays and sets and other numerous combinations using the same set of matchers. Groovy def errorMessage = generateErrorMessage() errorMessage.should == "insufficient disk space" // string and string equality comparison def numberAsText = "200" numberAsText.shouldBe > 150 // text and number relative comparison 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 String numberAsText = "200"; actual(numberAsText).shouldBe(greaterThan(150)); // text and number relative comparison Check matchers/import-and-dependencies Import And Dependencies for prerequisites.

Reporting

Every comparison failed and successful generates console output with comparison details. . [value] equals "insufficient disk space" (0ms) Values have predefined names when they come from HTTP response or Web UI, etc. But regular values default to value .Pass name as a second parameter to actual to set an explicit reporting name. Groovy double price = calculatePrice() actual(price, "price").shouldBe > 10 // explict name to use in reporting Java double price = calculatePrice(); actual(price, "price").shouldBe(greaterThan(10)); // explict name to use in reporting . price greater than 10 (1ms)

Dates

Universal compare lets you compare dates, local dates, strings, and times with timezones against each other. Groovy def dateAsText = "2018-06-10" dateAsText.shouldBe > LocalDate.of(2018, 6, 9) def timeAsText = "2018-01-02T00:00:00Z" timeAsText.shouldBe > LocalDate.of(2018, 1, 1) // date/time will be converted to local timezone def withTime = LocalDateTime.of(2022, 3, 16, 10, 4, 4) def dateOnly = LocalDate.of(2022, 3, 16) withTime.should == dateOnly // comparison ignores time portion when not provided Java String dateAsText = "2018-06-10"; actual(dateAsText).shouldBe(greaterThan(LocalDate.of(2018, 6, 9))); String timeAsText = "2018-01-02T00:00:00Z"; actual(timeAsText).shouldBe(greaterThan(LocalDate.of(2018, 1, 1))); // date/time will be converted to local timezone LocalDateTime withTime = LocalDateTime.of(2022, 3, 16, 10, 4, 4); LocalDate withDate = LocalDate.of(2022, 3, 16); actual(withTime).should(equal(withDate)); // comparison ignores time portion when not provided