Just encountered this recently. And was just wondering what other folks
have done. This is with respect to Java and JUnit, but should also apply to
other platforms (.NET/Nunit, etc.) and TestNG.

Asserts (JUnit at least) are most useful when you compare objects or plain
true/false. If you're comparing something like contains(text), regular
expression matching for true/false, it might be lacking where you use
AssertTrue or AssertFalse, and you can't quite use AssertEquals since
you're using methods like contain that return true/false. I meant lacking
in that all you get on fail is what the boolean value is but not what the
value of the text or other data being checked for is.

The workarounds might be to:

* manually run test through debugger and print/log statements to track the
value of data you're interested in
* use custom assert type method instead that does if/else checks and throws
exception with the actual and expected values
* use advanced assert features like assertThat() and matchers for JUnit 4
* something else I didn't mention?

Regarding assertThat, see this good post:

http://stackoverflow.com/questions/1701113/why-should-i-use-hamcrest-matcher-and-assertthat-instead-of-traditional-assert

AssertThat seems really nice, but requires some getting used to and some
good Java skills to use it well.

So what workarounds do you guys use?

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to selenium-users@googlegroups.com.
To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/KxQQE0AkUmcJ.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupselenium-users @
categoriesselenium
postedDec 8, '12 at 4:08a
activeDec 8, '12 at 4:08a
posts1
users1
websiteseleniumhq.org

1 user in discussion

David: 1 post

People

Translate

site design / logo © 2022 Grokbase