ElkArte Community

Project Support => General ElkArte discussions => Topic started by: emanuele on December 09, 2013, 06:05:08 am

Title: Ongoing simple thing todo: QA testing
Post by: emanuele on December 09, 2013, 06:05:08 am
Several months ago, Norv introduced some unit testing in the "system":
https://github.com/elkarte/Elkarte/tree/master/tests
based on SimpleTest (http://www.simpletest.org/) (nothing to do with Simple Machines).

A while ago, I played a bit with them, github and
Travis (https://travis-ci.org/elkarte/Elkarte/) so that on any pull request and any merge the tests are automatically run and if there is any issue we should be able to know before merging the pull request or soon after.

So, why this post?
Well, at the moment we have just a small bunch of very basic tests, and since write tests is usually rather simple, it could be yet another way to start contributing! :D

The organization of the tests is (hopefully) rather simple:

To know what a test looks like you can open one of those already present, for example:
https://github.com/elkarte/Elkarte/blob/master/tests/sources/subs/TestBoards.subs.php
This files has two tests:

If you feel like you want to give it a try, feel free, there is a lot to that is not covered by tests and more tests we have less bugs we should be able to introduce! Spoiler (click to show/hide)
Title: Re: Ongoing simple thing todo: QA testing
Post by: emanuele on December 17, 2013, 09:12:02 am
Recently added tests:
  • basic bbc code
  • html to bbc
  • data validator
  • basic likes
  • verification that the tables are created during install
  • basic registration
Title: Re: Ongoing simple thing todo: QA testing
Post by: emanuele on January 19, 2014, 10:22:18 am
One of the last things I did last year about testing is make them independent one from the other, now each test runs as an exec command, that ensure the tests are properly self-executed (and as such self-contained).

Another small goodies I added is that when the series of tests is completed (successfully or not) the travis-ci script grabs the content of the error log and outputs it to the console.
At the moment it doesn't raise any error, but from time to time it is useful, for example:
https://travis-ci.org/elkarte/Elkarte/jobs/17197799#L445
the first error is "normal" (it's generated while testing the registration), but the other two are not, they are two legit bugs I introduced while changing something else. ;D

In my plans there is to create a test to check if the log is empty (a general one to be run at the end of everything). There is a bit to play with though, because in the log there may be legit errors. One option is in each test to cleanup any "expected" error that may popup, for example in the current case, part of the tearDown method in TestRegistration could be to fetch the error and remove it. At that point, what is left is clearly a bug and could be reported as a "build breaker".
Title: Re: Ongoing simple thing todo: QA testing
Post by: Spuds on January 19, 2014, 11:29:03 pm
/me wipes sweat from brow that you did not use one of my broken PR's as the example :D

All the Travis work is really very very cool, has saved us a bunch of errors already!
Title: Re: Ongoing simple thing todo: QA testing
Post by: emanuele on February 09, 2014, 05:54:51 am
Teh @Spuds is shy and didn't tell people that he added another toy to the collection: https://scrutinizer-ci.com/
In particular: https://scrutinizer-ci.com/g/elkarte/Elkarte/

What does scrutinizer do?
It checks the code looking for broken things, for example methods or functions not existing, methods or functions not used, bad documentation, bad coding style, and many other things.
It runs on each pull request, so before merging there is another test that will help ElkArte to be less broken and so allow easier development and faster release cycle! :D
Title: Re: Ongoing simple thing todo: QA testing
Post by: Xarcell on February 09, 2014, 09:07:15 am
Quote from: emanuele – Teh @Spuds is shy and didn't tell people that he added another toy to the collection: https://scrutinizer-ci.com/
In particular: https://scrutinizer-ci.com/g/elkarte/Elkarte/

What does scrutinizer do?
It checks the code looking for broken things, for example methods or functions not existing, methods or functions not used, bad documentation, bad coding style, and many other things.
It runs on each pull request, so before merging there is another test that will help ElkArte to be less broken and so allow easier development and faster release cycle! :D


Cool.
Title: Re: Ongoing simple thing todo: QA testing
Post by: Spuds on February 09, 2014, 10:23:00 am
Its been a fun toy to play with  8) and its found several legit bugs in the code that we have fixed.  

There are lots of the mundane documentation issues, style issues as well, but the real joy is that it does find bugs and unused code that would be difficult to find otherwise.  It does take looking at each area that gets highlighted and determining why that area got flagged, some are obvious, some not so much, but in the end its creating a better product.
Title: Re: Ongoing simple thing todo: QA testing
Post by: emanuele on March 16, 2014, 04:37:00 pm
One thing that I just discovered would greatly benefit from automated testing is the moderation area. Mainly because it's something not that used.
But, in order to be able to test the basis there are several things to do, because there are tons of variants, so the easiest are:

And this is just about reporting, but the moderation area is also about unapproved posts (and then there are posts posted by members without permission and posts that are unapproved that need to be inserted and tested for both approval and deletion), and members, and emails, etc...

Well, this need is now tracked, sooner or later someone will create a test. ;D