unit testing - How can I reduce the failure display in specs2 -
i'm trying compare 2 big arrays using specs2. unfortunately when arrays not equal displays content of each of arrays under actual , expected. there anyway can either cut down amount of info displayed actual , expected or remove exclusively particular test.
i have tried using setmessage doesn't impact actual , expected part.
class="lang-scala prettyprint-override">bytes1 must be_== (bytes2).setmessage("a not mach b") what i'm trying compare 2 input streams. i'm interested hear if has improve thought on how instead of converting them arrays.
you can command how differences handled implementing own diffs trait:
import org.specs2._ import main._ class mydiffs extends diffs { /** @return true if differences must shown */ def show: boolean = true /** @return true if differences must shown 2 different strings */ def show(expected: string, actual: string): boolean = expected.size + actual.size < 100 /** @return diffs */ def showdiffs(expected: string, actual: string): (string, string) = (expected.take(10).mkstring, actual.take(10).mkstring) /** @return true if total strings must shown */ def showfull: boolean = false /** method not used , removed trait in next release */ def separators: string = "" } class s extends specification { def = args.report(diffs = new mydiffs)^ "test" ! { "abcdefghijklmnopqrstu" must_== "abcdefghijklmnopqrstuvwxyz" } } x test 'abcdefghijklmnopqrstu' not equal 'abcdefghijklmnopqrstuvwxyz' (<console>:47) expected: qrstuvwxyz actual: lmnopqrstu unit-testing scala testing specs2
No comments:
Post a Comment