xUnit Equivalent of MSTest’s Assert.Inconclusive

Best thing one can do until something is implemented in the library is to use Xunit.SkippableFact: [SkippableFact] public void SomeTest() { var canRunTest = CheckSomething(); Skip.IfNot(canRunTest); // Normal test code } This will at least make it show up as a yellow ignored test case in the list. Credit goes to https://stackoverflow.com/a/35871507/537842

Java assertions underused

assertions are, in theory, for testing invariants, assumptions that must be true in order for the code to complete properly. The example shown is testing for valid input, which isn’t a typical usage for an assertion because it is, generally, user supplied. Assertions aren’t generally used in production code because there is an overhead and … Read more

CollectionAssert in jUnit?

Using JUnit 4.4 you can use assertThat() together with the Hamcrest code (don’t worry, it’s shipped with JUnit, no need for an extra .jar) to produce complex self-describing asserts including ones that operate on collections: 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))); … Read more

AssertEquals 2 Lists ignore order

As you mention that you use Hamcrest, So I would pick one of the collection Matchers import static org.hamcrest.collection.IsIterableContainingInAnyOrder.containsInAnyOrder; import static org.junit.Assert.assertThat; public class CompareListTest { @Test public void compareList() { List<String> expected = Arrays.asList(“String A”, “String B”); List<String> actual = Arrays.asList(“String B”, “String A”); assertThat(“List equality without order”, actual, containsInAnyOrder(expected.toArray())); } }

What is the expected syntax for checking exception messages in MiniTest’s assert_raises/must_raise?

You can use the assert_raises assertion, or the must_raise expectation. it “must raise” do assert_raises RuntimeError do bar.do_it end -> { bar.do_it }.must_raise RuntimeError lambda { bar.do_it }.must_raise RuntimeError proc { bar.do_it }.must_raise RuntimeError end If you need to test something on the error object, you can get it from the assertion or expectation like … Read more