Custom name for BOOST_DATA_TEST_CASE - boost

Using googletest you can name your parameterized tests based on the parameters using the last argument in INSTANTIATE_TEST_SUITE_P.
Now I am using BOOST_DATA_TEST_CASE, and the tests are currently named _0, ..., _N which makes them hard to distinguish. Is there any way that the boost tests can be named in a similar way to googletests parameterized tests?

Related

Depenent JvmModelInferrer invoked twice?

tldr;
When I build a project with DSL-B (that depends on DSL-A) the generateXtext gradle task executes the JvmModelInferrer of DSL-A too often.
Details
Here is a simple example to reproduce the issue: ex.xtext.twog
there are 2 xtext projects:
DSL A: grammar a which is independent
DSL B: grammar b, which references grammar a
and 2 demo projects, which use the xtext projects:
demo/demoA: (uses DSL a) with this simple model def DefStr java.lang.String
demo/demoB: (uses DSL b) with this simple model use UseStrCls DefStr
I've added some debug-log messages to the JvmModelInferrers to see what's going on.
The xtext generation in demoB calls the AJvmModelInferrer 3 times (see build output):
:demoB:generateXtext
AJvmModelInferrer: infer definition=DefStr isPreIndexingPhase=true
AJvmModelInferrer: infer definition=DefStr isPreIndexingPhase=false
BJvmModelInferrer: infer use=UseStrCls isPreIndexingPhase=true
BJvmModelInferrer: infer use=UseStrCls isPreIndexingPhase=false
AJvmModelInferrer: infer definition=DefStr isPreIndexingPhase=false
Why is AJvmModelInferrer called again after BJvmModelInferrer?
Note: I could not find good docs or examples on how to use multiple grammars, so it's well possible, that I am doing something wrong in my setup-here are the relevant parts:
BStandaloneSetup.createInjectorAndDoEMFRegistration() calls AStandaloneSetup.doSetup()
gradle.build of project demoA adds src/main/java as resource dir, so that the xtext-model A is in the jar file (and thus demoB can find it)

Google Test: variable number of parameters for tests in the same test case

I have just started studying a code base which uses Google Test as testing framework (which I am not familiar with). Parameterized tests are extensively used more or less in what I believe is the usual way:
class TestCaseName: public ::testing::TestWithParam<Params> {
// fairly complex setup
}
TEST_P(TestCaseName, TestName) {...}
INSTANTIATE_TEST_CASE_P(UniqueName, TestCaseName, CombinedInput);
The problem is that often tests need some specific additional input.
It could be possible to create different versions of TestCaseName with different values of Params, but that would duplicate a fair amount of code.
Otherwise, it could be possible to add a single parameter to Params, corresponding to a custom AdditionalInput class which contains fields for all possible additional input. Extending TestCaseName as needed, the setup could be specialized.
Are there better approaches to solve this problem?

Accommodating to changes in target of transfer properties file in soapUI

I have a script evaluation scenario where the namespaces of my request WSDL will be different only in namespace from one another, due to which the testing(by importing test suite) for the request using property transfer in soapUI is becoming difficult because i have to change my property transfer's target namespace each time because of change in namespace.My requirement is create a test suite which can work for all scenarios.Please suggest a method.
SOAPUI Version-5.2.1
SOAPUI accept a * as a wildcard for namespaces. So if you've something like:
declare namespace ns='http://www.openuri.org/';
//ns:Root/ns:someNode
You can safety simplify your XPath to something like:
//*:Root/*:someNode
Or event shorter (if there are same node names in a different hierarchy):
//*:someNode
Since there is no sample of your user case I give you a general approach for your problem.

How to initialize test class resources in Visual Studio Unit Testing framework?

I'm using the unit testing framework in .NET in C++/CLI to test unmanaged C++ code.
I would like for example an instance of System::Random to generate random values throughout the test methods.
Do I need to put this as a member variable in my test class?
If yes where can I put the initialization code, cause the ClassInitialize() method that is generated is static for some reason and it only has access to a TestContext which I read is only for using testing data from some external sources.
You can add static properties to your test class and initialize them in the ClassInitialize() method if you need them to be available to all tests. If you want them initialized per test, then using the TestInitialize() method is better.
Are you sure you want to use random values in your unit tests? Typically you'd want to use known values (good values, bad values, edge cases, etc) so that your tests are predictable. Using multiple tests with various values where you know the expected behavior (outcome) is more typical than using random values.

MBUnit - Calling the same method multiple times in a sequence?

Is there a way in MBUnit to have the same test called multiple times with different parameters in a sequence, as such:
Method1()
Method2(param A)
Method3()
Method2(ParamB)
Method4()
Method2(ParamC)
etc? I've tried using the Order parameter but sadly I was too hopeful in that the Ordering would be considered class-wide rather than test-wide (1,2,3,4,5,6 as opposed to 1,2a,2b,2c,3,4).
Can you explain the reasons for needing this? This sounds like you have dependencies between your test methods, which in general isn't a good way to go about writing test code.
If you need something to be called in a particular sequence then why not simply expose it as a single test method which calls certain submethods in the order of your choosing?

Resources