6 Temmuz 2009, PAZARTESİ
JUnit içinde CollectionAssert?
JUnit bir paralel CollectionAssert NUnit var mı?
CEVAP
6 Temmuz 2009, PAZARTESİ
Kullanarak JUnit 4.4 kullanabilirsiniz assertThat()
birlikte Hamcrest code (merak etmeyin, bu sevk ile JUnit, gerek yok ekstra .jar
) üretmek için karmaşık kendini tarif onayları dahil olanlar ameliyat koleksiyonlar:
import static org.junit.Assert.assertThat;
import static org.junit.matchers.JUnitMatchers.*;
import static org.hamcrest.CoreMatchers.*;
List<String> l = Arrays.asList("foo", "bar");
assertThat(l, hasItems("foo", "bar"));
assertThat(l, not(hasItem((String) null)));
assertThat(l, not(hasItems("bar", "quux")));
// check if two objects are equal with assertThat()
// the following three lines of code check the same thing.
// the first one is the "traditional" approach,
// the second one is the succinct version and the third one the verbose one
assertEquals(l, Arrays.asList("foo", "bar")));
assertThat(l, is(Arrays.asList("foo", "bar")));
assertThat(l, is(equalTo(Arrays.asList("foo", "bar"))));
Otomatik olarak yüklenecektir iyi bir açıklama olacaktır bu yaklaşımı kullanarak başarısız olduğunda belirt.
Bunu Paylaş:
&Quot;animasyonlu Daire" kullanara...
Arasındaki fark "teşhir" ve ...
İddia UİTableViewController içinde UİS...
junit & java : halka açık olmayan yönt...
Nasıl Jilet gibi bir görünüm dosyası i...