Xojo Unit

So after having a good discussion at the Atlanta Xojo meeting last night, I am going to write up a doc on how to use Xojo Unit. So please send me an email or private message here with any comments, questions or concerns about Xojo Unit. As I write the doc, I want to make sure that I address all of them.

So fire away!

Great thing you plan, Scott! XojoUnit is one of those examples I look at … and look at … and don‘t get a clue except that I think it is some valuable instrument way beyond my scope.

XojoUnit is also documented in User Guide Book 4: Development, Chapter 6: Unit Testing.

and XojoUnit is very valuable. We use it extensively and would encourage anyone to take the time to learn and use it. At times it can seem a bit boring and non-productive, but that’s not at all true. Test Driven Development is fantastic!

There is some documentation there but it is lacking. Including how to extend it. Why you should use it. etc.

Sure, the more information about it, the better. And don’t forget that Marc wrote about it in XDev Magazine 11.6.

One of the first things I did was extending it.
My tests are still a work in progress.

I have read three books on unit testing, and they all agree that it is a really important part of software development. My only issue is working out HOW to make it all work.

Any efforts you make Scott will be well received !

Regards,
Tony Barry

tests are always a work in progress. As time goes on, you get to add more (after you find bugs, or edge cases) and you get to “cleanup” older tests with better code (like anything else we work on).

@Tony, I will want to make sure the “how” is in there. The issue at hand is you read 3 different books on Unit Testing and you are still not ready to use it. That is not a slam against you. That is very common. Unit Testing books (or articles) tend to either be way to high level and generic that you dont get how to implement or what to down in the weeds that you get how to implement with that test suite with that language with that one specific app. One extreme or the other.

After my talk a few years back (XDC12) I have talked to many people that are in the same boat as you are. They need something that is much lower level than most books but a little higher than most articles. Now the article that @Marc Zeedar wrote on the subject was good and generally at the right level. (xDev 11.6) It is 14 pages of good reading. I feel that there is more that could be said on the subject. But it is hard in a magazine article.

Please send me the questions you have so I can make sure I answer them.

XojoUnit is now on GitHub:

https://github.com/xojo/XojoUnit

I did put the docs from the User Guide into the GitHub wiki. That might be a good place for additional docs as well.

Note: I’ve only put up XojoUnitDesktop for now (since that appears to be the most commonly used). I’ll get the web and console versions uploaded soon.

that is awesome Paul.

I am building a web app and want to make Unit Tests run when the app is launched under the debugger, but run without the Unit Test Page showing … unless there is an asserted error.

i.e. test every time the app is run, but perform the test silently unless an error occurs (and then open the Test Page).

How do I modify the Unit Test environment to do this ?

I have read the docs (poor, and with one glaring error) and Marc Zeedar’s article in xDev11.6 (which has got me to the point where the Unit Tests run), but the Unit Test environment remains quite obscure to me, and definitely not straightforward in the way that Xojo is touted to be.

Regards,
Tony Barry

Even after using REALbasic, Real Studio and Xojo during 17 years, I found obscure docs everywhere.

Worst, reading this forum shows me that I am not alone (usually, but not exclusive, newbies).

So, Scott: good idea. How Atlanta Users are lucky ;-:slight_smile:

Hi Emile,

Yeah the docs are a bit pokey. But better than they were when Andrew Barry was putting out nightly builds of CrossBasic.

The books * say that Unit Tests should be run every time you compile, and they should run quickly, and keep out of the way unless they have a problem to report. Xojo Unit Testing harness does not really do this out of the box. But it can be made to do so.

I worked out how to do the task, it’s a bit kludgey. But it works.

  • Roy Osherove, The Art of Unit Testing; Michael Feathers, Working Effectively with Legacy Code; etc

Regards,
Tony Barry
Sydney

As puzzling as Xojo documentation be sometimes, it is so much better than Microsoft or Apple’s.

I especially love the numerous examples.

Paul Lefebvre really has done an amazing job.

[quote=205637:@Tony Barry]I am building a web app and want to make Unit Tests run when the app is launched under the debugger, but run without the Unit Test Page showing … unless there is an asserted error.

i.e. test every time the app is run, but perform the test silently unless an error occurs (and then open the Test Page).

How do I modify the Unit Test environment to do this ?[/quote]
The docs don’t describe how to modify Xojo Unit, only how to use it.

In general, if you do not want a UI, then you’ll probably want to adapt the code from the Console version (see Run event).

And a reminder to everyone that Xojo Unit is on GitHub. You can submit Issues there (including feature requests to have the UI versions run without the UI) and add to the docs that are in the wiki.

Thank you Paul. I had not considered the Console version. Good idea.

I have progressed with incorporating Unit Tests into the web app. I am getting close to uploading a web version to Xojo Cloud to see how it goes.

If I crash and burn I shall undoubtedly be back, with tears in my eyes and a pile of broken bytes :slight_smile:

Heh.

Regards
Tony Barry

I do not care much about Microsoft documentation, and I do not expect anything from Apple in this point of view (or the reverse if it pleased you).

The fact are if you do not know the technology (or if you are not the one[s] that asked its inclusion) before Xojo add it into out preffered development environment, you are a bit in a trouble.

How many of us do not use RegEx (or by exception), Control Subclass (excepted for dynamic Menus), etc. (add here all added technologies from the last 5 years) in their projects (new and old at updage time) ?