I want to use the filter argument to pio test
to only run the tests from one of my test files or test directories.
Like in the example below, I want to only run the tests in test_partone.hpp
, or only the tests of the SomeClass directory. How do I do this?
The docs say the filter checks the “name” of the test. But what is the “name”. FIlename? Function name? Function name including class/namespace/etc? Something else? Can someone clarify this for me? So far, whatever I do, if I do anything more specific than -f test_desktop
, (matching the first directory level of the tests) it doesn’t run any tests. I tried many different variations, including wildcards.
test/test_desktop/
test/test_desktop/test_main.cpp
test/test_desktop/test_main.h
test/test_desktop/SomeClass/
test/test_desktop/SomeClass/test_main.hpp
test/test_desktop/SomeClass/test_partone.hpp
test/test_desktop/SomeClass/test_parttwo.hpp
test/test_desktop/test_main.cpp
contains the following:
#include "test_main.h"
#include "SomeClass/test_main.hpp"
int main(int argc, char **argv) {
test_someclass::main(argc, argv);
return 0;
}
test/test_desktop/SomeClass/test_main.hpp
contains the following:
#pragma once
#include "test_partone.hpp"
#include "test_parttwo.hpp"
namespace test_someclass {
int main(int argc, char **argv) {
test_someclass_partone::main();
test_someclass_parttwo::main();
return 0;
}
}
and test/test_desktop/SomeClass/test_partone.hpp
contains the real tests like this (and test_parttwo.hpp the same, just with a different namespace):
#pragma once
#include <unity.h>
namespace test_someclass_partone {
void sometest() {
TEST_ASSERT_EQUAL(1, 1);
}
int main() {
UNITY_BEGIN();
RUN_TEST(some_test);
UNITY_END();
return 0;
}
}