Ticket Created
over 3 years ago

WERETECH-12587

Test methods is(), isnt() and ok()

I think it is nice to have some easier, less typing test method function names:

* Test.assertEqualMessage() as is()
* Test.assertNotEqualMessage() as isnt()
* Test.assertMessage() as ok()

This would allow way less typing, eg:

Test.is(needle, haystack, "Needle found in the haystack");
Test.isnt(needle, haystack, "Nope");
Test.ok(error instanceof Lang.ValueOutOfBoundsException, "Correct error is thrown");

  • Test::More in Perl, see https://metacpan.org/pod/Test::More

    Test2 in Perl exposes a similar API.

    You also have npm's TAP, they use equal and not instead of is and isnt: https://node-tap.org/docs/api/asserts/

    I use vim. I can work around it by my current method where I have a wrapper class.

    I think the whole assertXXXX is ultra verbose in a test suite, you assert it by default, that is why you call the test function.

  • I have seen many testing frameworks. Is there some precedent for using the names is, isnt and ok? The names we are using now are loosely based on the functionality of JUnit. I do agree we could add functionality (assertTrue, assertFalse, assertNotEquals, assertNull, assertNotNull, assertSame, assertNotSame, ...) to make Test more useful, but I don't really see that these new names buy us anything.

    If you're just trying to reduce typing, why not take advantage of the autocomplete feature of the vscode?

  • Perhaps additionally, you could have isa(), which does this:

    Test.instanceOf(error, Lang.ValueOutOfBoundsException, "Correct error is thrown");
    // of the shorter version:
    Test.isa(error, Lang.ValueOutOfBoundsException, "Correct error is thrown");