Rspec: “array.should == another_array” but without concern for order
Try array.should =~ another_array The best documentation on this I can find is the code itself, which is here.
Try array.should =~ another_array The best documentation on this I can find is the code itself, which is here.
You could also use PutsMail to test your emails before sending them. PutsMail is a tool to test HTML emails that will be sent as campaigns, newsletters and others (please, don’t use it to spam, help us to make a better world). Main features: Check HTML & CSS compatibility with email clients Easily send HTML … Read more
There is an indexOf method that all arrays have (except Internet Explorer 8 and below) that will return the index of an element in the array, or -1 if it’s not in the array: if (yourArray.indexOf(“someString”) > -1) { //In the array! } else { //Not in the array } If you need to support … Read more
My tests just seems so tightly bound to the method (testing all codepath, expecting some inner methods to be called a number of times, with certain arguments), that it seems that if I ever refactor the method, the tests will fail even if the final behavior of the method did not change. I think you … Read more
Here is my fancy version: import org.gradle.api.tasks.testing.logging.TestExceptionFormat import org.gradle.api.tasks.testing.logging.TestLogEvent tasks.withType(Test) { testLogging { // set options for log level LIFECYCLE events TestLogEvent.FAILED, TestLogEvent.PASSED, TestLogEvent.SKIPPED, TestLogEvent.STANDARD_OUT exceptionFormat TestExceptionFormat.FULL showExceptions true showCauses true showStackTraces true // set options for log level DEBUG and INFO debug { events TestLogEvent.STARTED, TestLogEvent.FAILED, TestLogEvent.PASSED, TestLogEvent.SKIPPED, TestLogEvent.STANDARD_ERROR, TestLogEvent.STANDARD_OUT exceptionFormat TestExceptionFormat.FULL } info.events … Read more
JUnit allows providing rules through a test class field or a getter method. What you annotated is in Kotlin a property though, which JUnit won’t recognize. Here are the possible ways to specify a JUnit rule in Kotlin: Through an annotated getter method From M13, the annotation processor supports annotation targets. When you write @Rule … Read more
Or you can skip rake and use the ‘rspec’ command: bundle exec rspec path/to/spec/file.rb In your case I think as long as your ./spec/db_spec.rb file includes the appropriate helpers, it should work fine. If you’re using an older version of rspec it is: bundle exec spec path/to/spec/file.rb
Code coverage is a measurement of how many lines/blocks/arcs of your code are executed while the automated tests are running. Code coverage is collected by using a specialized tool to instrument the binaries to add tracing calls and run a full set of automated tests against the instrumented product. A good tool will give you … Read more
You could use the @Rule annotation with ExpectedException, like this: @Rule public ExpectedException expectedEx = ExpectedException.none(); @Test public void shouldThrowRuntimeExceptionWhenEmployeeIDisNull() throws Exception { expectedEx.expect(RuntimeException.class); expectedEx.expectMessage(“Employee ID is null”); // do something that should throw the exception… System.out.println(“=======Starting Exception process=======”); throw new NullPointerException(“Employee ID is null”); } Note that the example in the ExpectedException docs is … Read more
A better way is to use the Stopwatch class: using System.Diagnostics; // … Stopwatch sw = new Stopwatch(); sw.Start(); // … sw.Stop(); Console.WriteLine(“Elapsed={0}”,sw.Elapsed);