Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unit testing a Firemonkey Application

I'm trying to use DUnit, which came with RAD Studio XE2, to unit testing a Firemonkey app (C++).

The problem is, DUnit is a VCL project, and this makes me unable to include the Firemonkey Unit Forms (ex.: UfrmMain.h) on the testing project.

Even if I separate the Visual with Logic (MultiTier/MVC), i cannot include any Firemonkey library into my classes (sometimes this would be useful, when there is a class "CustomDatabase" which have a object of type TConnection, that is only available in Firemonkey - of course only an example).

The testing is possible when i separate the firemonkey code completely and leave it on forms, and the logic/data kept on classes with pure C++ code.

So, this "handicap" is actually a good thing? Forcing me to work with MultiTier/MVC? (This thing in C++ is new to me) Or should i look for an alternative of unit testing, that lets me test forms too?

(Can you also recommend me some C++ project on github or code example which is separated in the mentioned way, where i can rely on?)

like image 671
Filipe Carvalho Avatar asked Mar 02 '12 13:03

Filipe Carvalho


1 Answers

One possible approach would be to use TextTestRunner rather than GUITestRunner. I've never actually tried this but I think it quite plausible that TextTestRunner does not use any VCL units, or at the very least what it does use can easily be excised. And indeed a quick scan of the source code suggests that this will work.

like image 118
David Heffernan Avatar answered Nov 01 '22 12:11

David Heffernan