Unit testing : 2 scenarios in one test?

google_tech_lead :

I want to know if I have a method to test :

public boolean validString(String str) {

Is is good to do a unit test like this :

public void should_valid_string() {

or it's better to do two tests ?

Jens Scharmann :

In my opinion this depends on how likely are your test cases fail all at once. In your example, if the first assert fails you don't know if the second one is ok. If you seperate them in two tests you get an atomic answer.

Guess you like