Expect item in array

Looks like you need a custom matcher. Depending on the version of Jasmine you are using: With Jasmine 1: this.addMatchers({ toBeIn: function(expected) { var possibilities = Array.isArray(expected) ? expected : [expected]; return possibilities.indexOf(this.actual) > -1; } }); With Jasmine 2: this.addMatchers({ toBeIn: function(util, customEqualityTesters) { return { compare: function(actual, expected) { var possibilities = Array.isArray(expected) … Read more

Spring Framework TEST RESTful Web Service (Controller) Offline i.e. No Server, No Database

Here is one suggestion that should give you some ideas. I assume that you are familiar with the SpringJUnit4ClassRunner and the @ContextConfiguration. Start by creating an test application context that contains PcUserController and a mocked PcUserService. In the example PcUserControllerTest class below, Jackson is used to convert JSON messages and Mockito is used for mocking. … Read more

Testing background color espresso Android

In my tests I have the following matcher for testing EditText color: public static Matcher<View> withTextColor(final int color) { Checks.checkNotNull(color); return new BoundedMatcher<View, EditText>(EditText.class) { @Override public boolean matchesSafely(EditText warning) { return color == warning.getCurrentTextColor(); } @Override public void describeTo(Description description) { description.appendText(“with text color: “); } }; } And usage is : onView(withId(R.id.password_edittext)).check(matches(withTextColor(Color.RED)));

How to test random numbers?

With most tests you can supply a large file of random numbers (integer or floating point) and run various tests on that sample file. DIEHARD worked that way, if I remember correctly and some others do, too. If you really want to see your generator fail, you could try using TestU01 by Pierre L’Ecuyer which … Read more

How to run golang tests sequentially?

You can’t / shouldn’t rely on test execution order. The order in which tests are executed is not defined, and with the use of testing flags it is possible to exclude tests from running, so you have no guarantee that they will run at all. For example the following command will only run tests whose … Read more