vstest.console.exe ListTests with FullyQualifiedName - vstest

/ListTests option of vstest is returning a list of test method names inside a dll.
Is there a way to return a list of FullyQualifiedNames?
So instead of getting TestMethodName I would like to receive NamespaceName.ClassName.TestMethodName.

You can use following command:
vstest.console a.dll /ListFullyQualifiedTests /ListTestsTargetPath:Tests.txt

Related

How to access Groovy script from SAP CPI Script Collection in another Script?

I try to access a groovy script from a script collection in another script (SAP CPI). The script from the script collection contains an enumeration and i want to access this enumeration in a message mapping script. So i do the following:
Create the script in the script collection (same package as the iFlow)
Reference the script in the integration flow
Import the enumeration and use it (it's a script function used in message mapping)
Simulate the mapping (which works if i copy enum to mapping script as well)
Runtime exception during processing target field mapping /ns1:Messages/ns1:Message1/PerPhone/PerPhone/phoneType. The root message is: Exception:[com.sap.aii.mappingtool.tf7.rt.BehaviorInvocationException: groovy.lang.MissingPropertyException: No such property: BonusScheme for class: Script29] in class com.sap.aii.mappingtool.tf7.ScriptHandler method addPicklistValue[[Ljava.lang.String;#1e57ab7f, [Ljava.lang.String;#29c56946, [Ljava.lang.String;#11ba6ab8, [Ljava.lang.String;#3d2f6b53, [Ljava.lang.String;#1e0033da, com.sap.aii.mappingtool.tf7.rt.ResultListImpl#1c8de605, com.sap.xi.mapping.camel.impl.MappingContextImpl#470ff907, com.sap.aii.mappingtool.tf7.rt.Context#5e20a086] on the exchange: Exchange[ID-ff2d2c8d-4286-4e5a-5b75-1556-1657430698694-1068-1]
Seems that my enumeration isn't known and therefore can't be referenced. I'm just asking myself - why? It's everything deployed. Someone has an idea?
I think You cannot reference a Script from Script Collection in a Messaging Mapping.
Even if you want to reuse a Common Script like getHeaders or getProperties Script as Custom Function from a Script Collection, You cannot.
it's just the way it was built.

How to parametrize JMeter Loop Controller with Groovy function?

I am pretty new to Jmeter but can handle "simple" test plans. I really do need help with the issue I am facing. Currently I run into a problem regarding how to parametrize the Loop Controller loop count Groovy function.
I did found a lot of examples but they are all with static loop count like: ${__groovy(new File('test.csv').readLines().size(),)}.
I really would like to parametrize the part 'test.csv'. Therefor I replaced that with ${csvFile}, like:
${__groovy(new File(${csvFile}).readLines().size(),)}.
In the 'User Defined Variables' section of the 'Test Plan' I created the variable 'csvFile'.
Test plan image in here
When I execute the script I retrieve an error in the log like:
2022-01-25 11:35:14,870 WARN o.a.j.f.Groovy: Error running groovy script
javax.script.ScriptException: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script16.groovy: 1: Unexpected input: '\' # line 1, column 12.
new File(D:\devenv\projecten\JM_InterestDeterminationService\inputmessages.csv).readLines().size()
^
1 error
Is the error pointing to the backslash? Is that because of the Windows OS?
Must I replace the '\' with a '/'? How and where can I do that?
I started fiddling around with .replaceAll("\\", "/") and .replaceAll("\\\\", "/"), but I don't know where to put it and what the correct syntax is.
Could any of you please help me?
That's one of the reasons why it's not recommended to inline JMeter Functions or Variables into Groovy scripts.
Just use vars shorthand for JMeterVariables class instance to read your csvFile variable value like:
${__groovy(new File(vars.get('csvFile')).readLines().size(),)}
and it should resolve your issue.
More information on this and other JMeter API shorthands: Top 8 JMeter Java Classes You Should Be Using with Groovy

integrating protractor with Jenkins

When I want to run specific test or suites. I run them from terminal.
I've installed jenkins and configured my first free style project.
I added shell command (ex: protractor conf.js --suites A --params.user =A).
Everything works fine. If I want to run multiple suites I must edit my shell command inside jenkins. Is there any workaround?, like checkboxes, so I can check which suites I want to run.
Also I want to know about extensible parameters. I want to select which parameters I want to run. Instead of putting command protractor conf.js --params.user=oneuser I want to be able to choose it from GUI.
Look into parameterized builds.
"First, you need to define parameters for your job by selecting "This build is parameterized", then using the drop-down button to add as many parameters as you need."
"String parameters are exposed as environment variables of the same name. Therefore, a builder, like Ant and Shell, [or protractor] can use the parameters."
So if you make "protractorSuites" a string parameter, you can reference it like:
protractor conf.js --suites ${protractorSuites} --params.user =A
Then when you "Build with parameters" you can supply the appropriate suite.

Is there any way to run an individual test method in groovy?

I'd like to run an individual test method instead of the entire test class in Groovy on the cli - is this possible?
So instead of all the test methods in MyTestClass, I'd like to run just the testArbitrary method in MyTestClass.
Any help appreciated.
In Intellij Idea you could create run configuration, that will start single test method. Command will be copied to output panel and will look like so
com.intellij.rt.execution.junit.JUnitStarter -ideVersion5 -junit3 package.TestClass,testMethod
Like this, you can create your custom JUnitStarter class as described here https://stackoverflow.com/a/9288513/1601606
Natively, there is no such class, but it's pretty simple to create it.

Fail hudson build with groovy script

I have a couple of post build actions that I run on my Hudson build. They are currently bash scripts, and if I want to fail the biuld from them, I just return a non-zero value. Is there a way to fail the build from another scripting language (such as groovy)? Do I just write a script that also returns non-zero? Or is there a particular plugin I need to enable this?
thanks,
Jeff
A way to do this programmatically within the Groovy script is:
throw new hudson.AbortException("Something was in my eye...")
The Groovy Postbuild Plugin seems to be what you need, and has a method called buildFailure() which sets the build result to FAILURE.
If your post build action is a standard build step (like a shell script). it is enough to exit that shell script with a non-zero value. I don't know if all scripting languages allow you to return a non-zero return value, that will then become the return value of the script (if you don't call exit or an equivalent command specifically in a script than the return value of the last executed command becomes the return value of the script).
If you have troubles with this approach, there is always the option to use the Log Parser Plugin to fail a build on error.

Resources