My XojoEZUnit testing framework

Hello Everyone!
I was using XojoUnit and wanted to make something a little simpler to use, with little to no setup for making unit tests. I ended up with my own little module I really like now named XojoEZUnit. Let me know what you think and be kind I haven’t really done many open source things that I actually think anyone has used, but I am moving into the space :slight_smile: . I doubt it is made to every standard and does not have 1:1 features with XojoUnit.

Also thank you to the people who contributed to XojoUnit, really wouldn’t of made this without them!


Check your color Assert, colors are RGBA: you check only RGB channels

1 Like

I’ll try and add that today! Also noticed another error in color for isnotequal that I forgot to do.

Fixed now hopefully.

I just started with Xojo, so apologies for asking dumb questions.

How do I see the results from a test without getting an unhandled exception that brings down the whole application? Do I have to wrap each assertion with a Try-Catch?

I have a set fail message function in the Results class to output info but I do need to make that better. I’ll try and put an update out this week! If you have any other feedback let me know!

The last line of Results.Fail is “Raise New XojoUnitTestFailedException(failedMessage,failedCode).” Once I commented this out, everything worked as I wanted: All the tests run and I can then look at which ones failed and which ones passed.

Maybe the exception-throwing should be an option, at least in BatchTest.

Some suggestions:

  • In the output, the user should be able to see the name of all the tests run (not just the failed ones), and whether each one passed or not. So, something like what test UIs usually show.

  • In Results.Display, a couple of blank lines before “System.DebugLog(”==============XojoEZUnit Results===================“)” and after “System.DebugLog(”================================================“).” This will help readability.

  • An option to output the results to a file. If the user runs a lot of tests in batch mode, scrolling up and down the Messages window is bit of a PITA.

1 Like

And also, thanks for XojoEZUnit. I’m just starting my first Xojo project, and since I’m using API 2, XojoUnit didn’t work for me. The thought of programming without unit testing was frightening.

Plus the ease of use with XojoEZUnit is really great.

1 Like

I actually was thinking of that same solution, like a “fail or message” boolean and “output style” that can be set. This is why I needed people to try it out so I can hit more use cases and how people test.

I’m happy people are using it and it works for API2. Like I said I’ll have this updated with your feedback this week (possibly tonight or tomorrow).

Your feedback has been incorporated into an update! Thank you and please let me know if it has any issues! I do this at night after my kid goes to bed haha.

You can now continue tests on failure of an assertion and write test results to a file using the function: XojoEZUnit.Results.SetResultsMode(continueOnFail as boolean, writeResultsToFile as FolderItem).