A small question about CPPunit testing
Jul 23, 2011 at 2:23pm UTC
Hey everyone, I got a small little question about cppunit. I'm kinda new to it.
I tried using some simple methods to test cppunit. It was a successful.
However there is some problem about my program.
When I start the test button, the running test bar stuck at 0.0% and doesn't seems like it's moving.
I can compile and run normally yet I can't test!!
Does anyone know why?
One simple example.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
#include <cstdlib>
#include <iostream>
using namespace std;
void a();
void menu(){
cout<<"A to going to the next function" <<endl;
a();
}
void a(){
cout<<"A going to menu" <<endl;
return ;
}
int main(int argc, char ** argv) {
menu();
return 0;
}
The default CPP test header
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
#ifndef NEWTESTCLASS1_H
#define NEWTESTCLASS1_H
#include <cppunit/extensions/HelperMacros.h>
class newtestclass1 : public CPPUNIT_NS::TestFixture {
CPPUNIT_TEST_SUITE(newtestclass1);
CPPUNIT_TEST(testMenu);
CPPUNIT_TEST_SUITE_END();
public :
newtestclass1();
virtual ~newtestclass1();
void setUp();
void tearDown();
void testMenu();
};
.cpp of the CPPunit test.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
#include "newtestclass1.h"
CPPUNIT_TEST_SUITE_REGISTRATION(newtestclass1);
newtestclass1::newtestclass1() {
}
newtestclass1::~newtestclass1() {
}
void newtestclass1::setUp() {
}
void newtestclass1::tearDown() {
}
void menu();
void newtestclass1::testMenu() {
menu();
if (true /*check result*/ ) {
CPPUNIT_ASSERT(true );
}
}
Anyone can help? I've been trying for days!!
Jul 24, 2011 at 4:26am UTC
anyone knows?
Topic archived. No new replies allowed.