To adopt this thing into my project, I've come an idea that is suited for my test case. The idea like this, for each test case, 2 folders will be created to mimic the source location and destination location. Thus I have a class named PrepareFile for this purpose, the constructor will invoke when each test case begins, and the destructor will invoke when the test case has ended:
class PrepareFile
{
public:
PrepareFile() {
create_directory("path_A");
create_directory("path_B");
BOOST_TEST_MESSAGE("Creating test folder");
}
~PrepareFile() {
remove_all("path_A");
remove_all("path_B");
BOOST_TEST_MESSAGE("Removing test folder");
}
};
/* Test case: Cap_T1
* Test scenario: path_A has one file
* Test result: one file is captured in index file
*/
BOOST_FIXTURE_TEST_CASE(Cap_T1, PrepareFile)
{
...
}
/* Test case: Cap_T2
* Test scenario: path_A has one file, path_B has one file.
* Test result: files in both paths has captured in index file.
*/
BOOST_FIXTURE_TEST_CASE(Cap_T2, PrepareFile)
{
...
}
I like this test framework structure because it could provide me a clean test environment. Anyhow, this is just a tiny test in my code, SIT effort is still required.

No comments:
Post a Comment