C++??????????? CppUnit
???????????? ???????[ 2013/11/19 16:33:37 ] ????????
????CppUnit -- ???C++??????????????????????????????????JUnit?????????????????????е???????????
????????????http://sourceforge.net/apps/mediawiki/cppunit/index.php?title=Main_Page
????1. ???
??????linux?o???????????????????????????????????Eclipse CDT???????????? cppunit ????????? link library
????2. ???????????????????????м?????????
#include <iostream>
//????CppUnit???????
#include "cppunit/TestCase.h"
#include "cppunit/TestResult.h"
#include "cppunit/TestResultCollector.h"
#include "cppunit/TestCaller.h"
#include "cppunit/TextOutputter.h"
using namespace std;
//????????????????
class SimpleCalculator {
public:
int add(int a?? int b) {
return a + b;
}
int sub(int a?? int b) {
return a - b;
}
int mul(int a?? int b) {
return a * b;
}
int div(int a?? int b) {
return a / b;
}
};
//?????????TestCase??
class SimpleCalculatorTest : public CPPUNIT_NS::TestCase {
public:
//????????????
virtual void setUp() {
pSc = new SimpleCalculator();
}
//????????????????
virtual void tearDown() {
delete pSc;
}
//???????
void testAdd() {
CPPUNIT_ASSERT_EQUAL(pSc->add(5??6)?? 11);
}
void testDiv() {
CPPUNIT_ASSERT_EQUAL(pSc->div(10??1)?? 0);
}
private:
SimpleCalculator *pSc;
};
int main() {
CPPUNIT_NS::TestResult tr;
CPPUNIT_NS::TestResultCollector resultCollector;
tr.addListener(&resultCollector);
//testAdd
CPPUNIT_NS::TestCaller<SimpleCalculatorTest> tcAdd("testAdd"?? &SimpleCalculatorTest::testAdd);
tcAdd.run(&tr);
//testDiv
CPPUNIT_NS::TestCaller<SimpleCalculatorTest> tcDiv("testDiv"?? &SimpleCalculatorTest::testDiv);
tcDiv.run(&tr);
CPPUNIT_NS::TextOutputter output(&resultCollector?? std::cout);
output.write();
return 0;
}
/*
CPPUNIT_ASSERT_EQUAL(pSc->div(1??10)?? 0);
OK (2 tests)
CPPUNIT_ASSERT_EQUAL(pSc->div(10??1)?? 0);
!!!FAILURES!!!
Test Results:
Run: 2 Failures: 1 Errors: 0
1) test: testDiv (F) line: 54 ../src/TestCppUnit3.cpp
equality assertion failed
- Expected: 10
- Actual : 0
*/
|
???????????????????????漰???????????????????SPASVOС??(021-61079698-8054)?????????????????????????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11????????
?????????App Bug???????????????????????Jmeter?????????QC??????APP????????????????app?????е????????jenkins+testng+ant+webdriver??????????????JMeter????HTTP???????Selenium 2.0 WebDriver ??????