First whats the class I use if I want to setup a test like:
class MyClassTests
setup()
teardown()
testDoingSomething()
testDoingA()
Seems like the class to use is TestSuite?
So now I just created a very simple class:
# ParserUnitTests.h
#include <cppunit\TestFixture.h>;
#include <cppunit\extensions\HelperMacros.h>
class ParserUnitTests : public CppUnit::TestFixture {
public:
void testCanDoUnitTest();
};
And its corresponding cpp:
#include "ParserUnitTests.h"
CPPUNIT_TEST_SUITE(ParserUnitTests);
void ParserUnitTests::testCanDoUnitTest() {
CPPUNIT_ASSERT_EQUAL(1, 2, "Expected failure");
}
CPPUNIT_TEST(ParserUnitTests::testCanDoUnitTest);
I am getting errors like "expected a declaration" on the CPPUNIT_TEST_SUITE line... seems very different from where I come from ... more modern languages ... like JS/Python ... Seems like here its more explicit? I must tell CppUnit which class/test cases to run? Ok, but whats causing the errors?
The code in the CppUnit cookbook is mainly snipplets and its hard to figure out what are the imports required and what should go where ... perhaps someone can guide me?