Overview
Features
Download
Documentation
Community
Add-Ons & Services

POCO's CppUnit - relevant informations

A general discussion forum.

POCO's CppUnit - relevant informations

Postby p47l4f0n » 17 Feb 2010, 22:49

Hi,
I would put together relevant informations about POCO's CppUnit stuff. There is few and poor informations about it. Importnant is, that POCO's CppUnit is quite different from the original CppUnit at sourceforge. An Example: TestRunner. So after some days with unsuccessfull trying to start to use the unit testing in POCO, I decided to ask this community of professionals here :geek:
There is a lot of simple examples on the internet! Yes, they are simple AND not usefull, because people need advanced and clear examples. Let's start.
Y35, I'm 4 n00b !
p47l4f0n
 
Posts: 12
Joined: 17 Feb 2010, 22:25

Re: POCO's CppUnit - relevant informations

Postby p47l4f0n » 18 Feb 2010, 11:54

Hi, I want to show, how I successfull run the simple unit test and where I found some bug.

I have this TestCase class:
Code: Select all
class CPositionTest : public TestCase {

   public:
      CPositionTest (string name) : TestCase(name) { }
      
      void testOperators ();

      static Test* suite () {
      
         TestSuite *suite = new TestSuite;

         TestCaller<CPositionTest> *cal = new TestCaller<CPositionTest> ("testOperators", &CPositionTest::testOperators);

         suite->addTest (cal);
         return suite;
      }
};


There is a problem in the TestCase.h and TestCaller.h files in some pseudodocumentation there..
Code: Select all
suite->addTest (new TestCaller<MathTest> ("testAdd", testAdd));

will not work, it will produce an error on compilation:
src/tests/CPositionTest.h: In static member function `static CppUnit::Test* CPositionTest::suite()':
src/tests/CPositionTest.h:28: error: no matching function for call to `CppUnit::TestCaller<CPositionTest>::TestCaller(const char[14], <unknown type>)'
include/CppUnit/TestCaller.h:59: note: candidates are: CppUnit::TestCaller<Fixture>::TestCaller(const std::string&, void (Fixture::*)()) [with Fixture = CPositionTest]
include/CppUnit/TestCaller.h:54: note: CppUnit::TestCaller<Fixture>::TestCaller(const CppUnit::TestCaller<Fixture>&) [with Fixture = CPositionTest]
mingw32-make: *** [obj/CPositionTest.o] Error 1


There in my example it's rewritten and it works:
new TestCaller<CPositionTest> ("testOperators", &CPositionTest::testOperators);
The string "testOperators" must not match the name of the class method.

Please, is this the right way to use the test cases :?: :?: Can you discus your experiences here?
Y35, I'm 4 n00b !
p47l4f0n
 
Posts: 12
Joined: 17 Feb 2010, 22:25

Re: POCO's CppUnit - relevant informations

Postby p47l4f0n » 18 Feb 2010, 12:00

Now I want to run the tests:

Code: Select all
int main (int argc, char **argv) {

   TestRunner runner;
   
   runner.addTest ("CPositionTest", CPositionTest::suite ());

   std::vector<std::string> args;
   
   args.push_back("-all");
   args.push_back("-print");
   args.push_back("-wait");
   args.push_back("testOperators");

   return runner.run (args) ? 0 : 1;
}


This will produce following output:
Y:\Work\Vectors>bin\tests.exe
CPositionTest
N7CppUnit10TestCallerI13CPositionTestEE.testOperators

testOperators:

OK (1 tests)
Y35, I'm 4 n00b !
p47l4f0n
 
Posts: 12
Joined: 17 Feb 2010, 22:25

Re: POCO's CppUnit - ON DEBIAN LENNY - cannot install

Postby p47l4f0n » 19 Feb 2010, 02:34

It's not possible to install POCO's CppUnit on lenny via APT (apt-get, aptitude, synaptic)
Why :?:

It's not possible to run ./configure script when trying to build POCO on linux from sources from POCO's web site (Get Poco)
user@debian:~/Downloads/poco/poco-1.3.6p2$ ./configure
bash: ./configure: /bin/sh^M: bad interpreter: není souborem ani adresářem
user@debian:~/Downloads/poco/poco-1.3.6p2$

there is some whitespace mess maybe :ugeek:

Did someone solve this problems?

Let's stop to use CppUnit, it's not usefull for profesionals :roll:
Y35, I'm 4 n00b !
p47l4f0n
 
Posts: 12
Joined: 17 Feb 2010, 22:25

Re: POCO's CppUnit - relevant informations

Postby guenter » 19 Feb 2010, 08:42

t's not possible to run ./configure script when trying to build POCO on linux from sources from POCO's web site (Get Poco)


Get the .tar.gz file instead of the .zip file (and read the text on the Downloads page).

Let's stop to use CppUnit, it's not usefull for profesionals


No one forces you to use it. CppUnit in POCO is meant for testing the library only. And we're not going to change that anytime soon. Unless a professional offers to spend a few weeks rewriting all of the hundreds of test cases for a new unit testing framework.
guenter
 
Posts: 1112
Joined: 11 Jul 2006, 16:27
Location: Austria

Re: POCO's CppUnit - relevant informations

Postby p47l4f0n » 19 Feb 2010, 11:45

guenter wrote:
t's not possible to run ./configure script when trying to build POCO on linux from sources from POCO's web site (Get Poco)


Get the .tar.gz file instead of the .zip file (and read the text on the Downloads page).

Ok, my misstake. So *.zip is meant just only for Windows and the others for the others.

guenter wrote:
Let's stop to use CppUnit, it's not usefull for profesionals


No one forces you to use it. CppUnit in POCO is meant for testing the library only. And we're not going to change that anytime soon. Unless a professional offers to spend a few weeks rewriting all of the hundreds of test cases for a new unit testing framework.

:lol: It was a joke.
:idea: But that's very importnant information :!: So, if we want to use unit testing, we should use the original CppUnit library? I fully understand and accept the reason. I will think about it, but first I will try to compile the POCO's CppUnit and use it for a while and test the original CppUnit, when it is possible to compile. Hm, let's see.
Does someone have similar experiences with CppUnit, or some suggestions?

Thank you Günter.
Y35, I'm 4 n00b !
p47l4f0n
 
Posts: 12
Joined: 17 Feb 2010, 22:25

Re: POCO's CppUnit - relevant informations

Postby killerbot » 19 Feb 2010, 16:28

I can suggest you the following unit tests framework : UnitTest++
http://unittest-cpp.sourceforge.net/
http://sourceforge.net/projects/unittest-cpp/
killerbot
 
Posts: 66
Joined: 03 Dec 2009, 12:55

Re: POCO's CppUnit - relevant informations

Postby p47l4f0n » 19 Feb 2010, 18:09

killerbot wrote:I can suggest you the following unit tests framework : UnitTest++
http://unittest-cpp.sourceforge.net/
http://sourceforge.net/projects/unittest-cpp/

Thank a lot :) Seems to be exactly what I want :)
Y35, I'm 4 n00b !
p47l4f0n
 
Posts: 12
Joined: 17 Feb 2010, 22:25


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest

cron