← Back to team overview

brewtarget-devs team mailing list archive

Re: Unit tests

 

I'm still thinking about how exactly to organize the tests and which ones
to write. I'd like suggestions after you guys look this over. Mostly, that
request was about structural changes that allow us to write the tests at
all.

In any case, the overall idea is to write test cases for things we don't
want to break. Now, all the testing consists of me running brewtarget and
making sure it doesn't segfault or do crazy things, which is really pretty
poor. We need some better way to test the software. For example, we might
want to enter a test recipe and make sure it always calculates the same
parameters going forward to ensure we don't break anyone's recipes. Since
we'd like to do this sort of thing programatically (by running 'make test'
or whatever), there is Qt stuff to make classes for testing and handle all
of that.

For now, the test cases are contained in Testing.h/cpp. If you want to add
a test case, just add public slot with signature 'void f(void)', using
QVERIFY, QVERIFY2, QCOMPARE (qFuzzyCompare for floats) etc. to make all the
assertions. The test cases will be run with 'make test' and a summary will
print detailing the failed assertions.

One thing to try and maintain is the isolation of the test cases. I don't
want the test cases to modify any database already in ~/.config/brewtarget,
and I don't want it to be affected at all by that data or whatever current
settings you have. This means the test cases depend _only_ on the data and
code currently in the repository and the test results should be repeatable
and consistent across machines. I think I achieved this isolation with
Testing::initTestCase() (run before all test cases), but I could be wrong.
This is critical, and I'd like your help to make sure we are achieving it.

I am not at all set on the structure of the test classes/cases. I'm hoping
that when we start to write more test cases, it will become evident how we
should organize them, and I'm looking for your input on that.


On Mon, May 12, 2014 at 8:46 AM, mik firestone <mikfire@xxxxxxxxx> wrote:

> I just resync'd master with upstream and noticed we are preparing for the
> v2.1 release. Yay! I will work on updating the manual.
>
> I also noticed that the build included a brewtarget_tests.dir. I am
> assuming this is the result of the unit tests Phil added.
>
> Phil, can you give us a quick rundown on how to use and write the tests?
>
> Thanks,
> Mik
>
> --
> In a world of ninja v. pirate, I pilot a Gundam
>
> --
> Mailing list: https://launchpad.net/~brewtarget-devs
> Post to     : brewtarget-devs@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~brewtarget-devs
> More help   : https://help.launchpad.net/ListHelp
>
>


-- 
Philip G. Lee
rocketman768@xxxxxxxxx

References