Hi everyone,
I’m starting to work on converting some of the existing tests to a more BDD-style structure, beginning with BClipboard. I wanted to share the approach I’m planning to use to make sure it aligns with expectations.
Since we don’t appear to have a Gherkin / cucumber-style framework in the current test infrastructure, the idea is to apply BDD directly in CppUnit, with the Given / When / Then flow encoded in the test method names, and comments used only when the name becomes too long or needs clarification.
The basic convention I’m following is:
Given<precondition>_When<action>_Then<expected_behavior>
(BClipboard construction)
Original tests were numbered cases. In BDD style, the same behavior would be expressed like this:
class BClipboardTester : public TestCase
{
public:
BClipboardTester() {}
BClipboardTester(std::string name) : TestCase(name) {}
// Feature: BClipboard creation
void GivenNullName_WhenClipboardIsCreated_ThenDefaultsToSystemClipboard();
void GivenValidName_WhenClipboardIsCreated_ThenNameIsPreserved();
static Test* Suite();
};
The second point is, how to compile an Individual Unit test particular to an application? Is there any thread I can refer to?
Feedback Welcome.