On 5 May 2015 at 07:31, Phil Nash <
pan.e...@gmail.com> wrote:
> On Wednesday, 22 April 2015 11:24:25 UTC+1, Mateusz Łoskot wrote:
>>
>> For example, what's the canonical way to pass arguments like
>> a database connection string?
>
> (1) Before you hand off to Catch parse the args however you like and
> extract the args you're interested in. Pass the rest into Catch. You could
> pass them all into Catch at this point but it will warn about unknown args.
The warning is not a problem.
I'm more concerned about nice and efficient way of making such arguments,
or custom configuration, available from inside the tests.
> (2) There is a way, which I don't have the details of to hand right now (can
> get back to you with this if you're interested) where you can pass the
> arguments into Catch at a lower level and tell it to return unused args to
> you, instead of complaining. You'll get them back in a pre-parsed form (this
> is actually Clara - the self-contained argument parser). You can then feed
> these back into Clara with your own arg spec
This sounds good, though how to access them inside the tests?
I can't see how I could feed Catch::Session with custom Config and ConfigData.
The only way would be to have own singleton object available for all tests,
then no need to parse the arguments by Catch itself
I realised, my scenario is more complicated than just arguments parsing.
It feels more like dynamic configuration of test cases
0. Two test cases
TEST_CASE("Oracle")
{
auto connection = ... // #1 passed as CATCH arg
soci::session sql(soci::oracle, connection);
...
}
TEST_CASE("DB2")
{
auto connection = ... // #2 passed as CATCH arg
soci::session sql(soci::db2, connection);
...
}
1. Built as single executable
2. Run: my_tests --oracle "Oracle connection" --db2 "DB2 connection string"
3. Test cases use --oracle argument in #1 and --db2 argument in #2, but how?
What would be a recommended solution for such scenario?