I'm trying to compare two very large arrays using specs2. Unfortunately when the arrays are not equal it displays the content of each of the arrays under actual and expected. Is there anyway I can either reduce the amount of data displayed for actual and expected or remove it entirely just for this particular test.
I have tried using setMessage but this doesn't affect the actual and expected part.
bytes1 must be_== (bytes2).setMessage("A does not mach B")
What I'm actually trying to do is compare two input streams. I'm also interested to hear if someone has a better idea on how to do that instead of converting them to arrays.
You can control how differences are handled by implementing your own Diffs
trait:
import org.specs2._
import main._
class MyDiffs extends Diffs {
/** @return true if the differences must be shown */
def show: Boolean = true
/** @return true if the differences must be shown for 2 different strings */
def show(expected: String, actual: String): Boolean =
expected.size + actual.size < 100
/** @return the diffs */
def showDiffs(expected: String, actual: String): (String, String) =
(expected.take(10).mkString, actual.take(10).mkString)
/** @return true if the full strings must also be shown */
def showFull: Boolean = false
/** this method is not used and will be removed from the trait in a next release */
def separators: String = ""
}
class s extends Specification { def is =
args.report(diffs = new MyDiffs)^
"test" ! {
"abcdefghijklmnopqrstu" must_== "abcdefghijklmnopqrstuvwxyz"
}
}
x test
'abcdefghijklmnopqrstu' is not equal to 'abcdefghijklmnopqrstuvwxyz' (<console>:47)
Expected: qrstuvwxyz
Actual: lmnopqrstu