Hello every one, I begin programming with the cppunit framework and i have a problem, here is my code
Code------------------------------
void OpNotTest::normalCaseTest(){
CPPUNIT_ASSERT_EQUAL(1, 3);
CPPUNIT_ASSERT_EQUAL(1, 1);
CPPUNIT_ASSERT_EQUAL(1, 4);
}
---------------------------------
When I test this function the result are :
Tests Result-------------------------
OpNotTest.cpp:73:Assertion
Test name: OpNotTest::normalCaseTest
equality assertion failed
- Expected: 1
- Actual : 3
-------------------------------------
The runing test stop in the first Failure! I want him to continue at the end of the function. And for a particular reason
I can't separate the 3 assetion, because my function will contain in the future many assertion.
Thank's for the helper
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Perhaps you are trying to test too many things at once. Your contrived example should be split up into three separate tests:
[code]
void OpNotTest::test1(){
CPPUNIT_ASSERT_EQUAL(1, 3);
}
This way you will see each assertion pass or fail.
When an assertion fails, it typically signals a bad state of the software system. Any assertions that succeed afterward are misleading since the state or input is possibly bad.
Of course, the above example is contrived, so perhaps we can get a better idea of what you want to do if you post some of your real code.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
So What I want to do is to test all the result of the function applyOperator() by the func. IsEqual() that's why I used CPPUNIT_ASSERT(). And i don't wnat that the program crash whitout terminating all the tests with IsEqual().
I hope that you have a better idea now of what i want to do.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
CppUnit is not designed to do what you describe. In fact, it sounds like you are trying to group several tests into one method. You need to separate these tests into several different methods as I described earlier. Typically, you should have only one CPPUNIT_ASSERT_XXX call per test method. The typical convention for grouping related tests is by putting them in a class. So perhaps you can make NormalOpNotTest, OutputForcingOpNotTest, and RobustnessOpNotTest classes with each of the appropriate test methods in each class. This is the way CppUnit is designed to handle a situation like you describe.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Okay, I see no one to help here! Not much documentation about CppUnit, no advanced example too...
I don't now why, but I think no one comes here to read our MSG !!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello every one, I begin programming with the cppunit framework and i have a problem, here is my code
Code------------------------------
void OpNotTest::normalCaseTest(){
CPPUNIT_ASSERT_EQUAL(1, 3);
CPPUNIT_ASSERT_EQUAL(1, 1);
CPPUNIT_ASSERT_EQUAL(1, 4);
}
---------------------------------
When I test this function the result are :
Tests Result-------------------------
OpNotTest.cpp:73:Assertion
Test name: OpNotTest::normalCaseTest
equality assertion failed
- Expected: 1
- Actual : 3
-------------------------------------
The runing test stop in the first Failure! I want him to continue at the end of the function. And for a particular reason
I can't separate the 3 assetion, because my function will contain in the future many assertion.
Thank's for the helper
Perhaps you are trying to test too many things at once. Your contrived example should be split up into three separate tests:
[code]
void OpNotTest::test1(){
CPPUNIT_ASSERT_EQUAL(1, 3);
}
void OpNotTest::test2(){
CPPUNIT_ASSERT_EQUAL(1, 1);
}
void OpNotTest::test3(){
CPPUNIT_ASSERT_EQUAL(1, 4);
}
This way you will see each assertion pass or fail.
When an assertion fails, it typically signals a bad state of the software system. Any assertions that succeed afterward are misleading since the state or input is possibly bad.
Of course, the above example is contrived, so perhaps we can get a better idea of what you want to do if you post some of your real code.
Thank's for the replay,
I explain to you what i want to do.
I have a class , OpNotTest that contain tree Test function :
void normalCaseTest();
void outPutForcingTest();
void robustnessTest();
These functions used a function : bool IsEqual(char *image1, char * image2) to test if the two images are the same
Example of use :
void OpNotTest::normalCaseTest(){
applyOperator(NC1_1, "NotResult.inr.gz");
CPPUNIT_ASSERT(IsEqual(NC_RES1_1, "NotResult.inr.gz"));
applyOperator(NC1_2, "NotResult.inr.gz");
CPPUNIT_ASSERT(IsEqual(NC_RES1_2, "NotResult.inr.gz"));
}
So What I want to do is to test all the result of the function applyOperator() by the func. IsEqual() that's why I used CPPUNIT_ASSERT(). And i don't wnat that the program crash whitout terminating all the tests with IsEqual().
I hope that you have a better idea now of what i want to do.
CppUnit is not designed to do what you describe. In fact, it sounds like you are trying to group several tests into one method. You need to separate these tests into several different methods as I described earlier. Typically, you should have only one CPPUNIT_ASSERT_XXX call per test method. The typical convention for grouping related tests is by putting them in a class. So perhaps you can make NormalOpNotTest, OutputForcingOpNotTest, and RobustnessOpNotTest classes with each of the appropriate test methods in each class. This is the way CppUnit is designed to handle a situation like you describe.
Okay, I see no one to help here! Not much documentation about CppUnit, no advanced example too...
I don't now why, but I think no one comes here to read our MSG !!