With Spock upgrade to 2.4-M1-groovy-3.0 we found out that test reports for our data driven tests (= using #Unroll Spock annotation) contain an additional "test case" and also counts the time of this "test case" to the total which means the total time doubles.
I searched the docs and it seems to be Spock 2's default feature to show the test results for data driven tests in a tree (e.g. when run in IDE) showing the tests hierarchy while Maven Surfire can probably show only a flat list:
Hence there is this umbrella "test case" which is quite confusing. Would anyone know how the get rid of the additional line in the report?
If I remember correctly you have to use this bit of config in your pom.xml
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
<configuration>
<statelessTestsetReporter implementation="org.apache.maven.plugin.surefire.extensions.junit5.JUnit5Xml30StatelessReporter">
<disable>false</disable>
<version>3.0</version>
<usePhrasedFileName>false</usePhrasedFileName>
<usePhrasedTestSuiteClassName>true</usePhrasedTestSuiteClassName>
<usePhrasedTestCaseClassName>true</usePhrasedTestCaseClassName>
<usePhrasedTestCaseMethodName>true</usePhrasedTestCaseMethodName>
</statelessTestsetReporter>
</configuration>
</plugin>
Related
I need help in RHPAM Business Central.
Anybody knows how to add any print statements or logs in DMN's for debugging DMN flow?
You can define your own DMNRuntimeEventListener.
The listener is usually wired in Drools library using: https://docs.drools.org/8.33.0.Final/drools-docs/docs-website/drools/DMN/index.html#dmn-properties-ref_dmn-models:~:text=org.kie.dmn.runtime.listeners.%24LISTENER_NAME
e.g.: with a configuration such as:
-Dorg.kie.dmn.runtime.listeners.mylistener=org.acme.MyDMNListener
or alternatively with analogous configuration in kmodule.xml
<kmodule xmlns="http://www.drools.org/xsd/kmodule">
<configuration>
<property key="org.kie.dmn.runtime.listeners.mylistener" value="org.acme.MyDMNListener"/>
</configuration>
</kmodule>
This latter option, is the one you might preference on RHPAM Business Central.
You might find helpful this tutorial: https://www.youtube.com/watch?v=WzstCC3Df0Q
I want to run my automated tests in TFS using a Custom Logger. Normally you would do this by adding something like /Logger:MyCustomLogger to the Other Console Options section of the Visual Studio Test Task.
You have the option to select tests by Assembly, Test Run ID, or Test Plan. If you select either Test Run or Test Plan, you are not able to set the Other Console Options value. Per the documentation:
Other console options that can be passed to vstest.console.exe, as documented here.
These options are not supported and will be ignored when running tests using the ‘Multi agent’ parallel setting of an agent phase or when running tests using ‘Test plan’ option. The options can be specified using a settings file instead.These options are not supported and will be ignored when running tests using the ‘Multi agent’ parallel setting of an agent phase or when running tests using ‘Test plan’ option. The options can be specified using a settings file instead.
I think thats because it uses TCM.exe instead of VSTest.Console.Exe, and TCM doesnt take the same console options, but not entirely sure.
According to the quote above, "The options can be specified using a settings file instead". My question is: What settings file allows you to provide a Logger? RunSettings doesnt support it (Though that may be addressed here).
So is there a workaround for this? Is there a way to provide a Logger while running a Test Plan?
Please check this documentation:
Runsettings via Logger node in the LoggerRunSettings section. Here
is a sample on how this can be specified:
<RunSettings>
<LoggerRunSettings>
<Loggers>
<Logger friendlyName="sampleLoggerwithParameters">
<Configuration>
<Key1>Value1</Key1>
<Key2>Value2</Key2>
</Configuration>
</Logger>
<Logger uri="logger://sample/sampleLoggerWithoutParameters1"
friendlyName="sampleLoggerWithoutParameters1" />
<Logger uri="logger://sample/sampleLoggerWithoutParameters2"
assemblyQualifiedName="Sample.Sample.Sample.SampleLogger,
Sample.Sample.Logger, Version=0.0.0.0, Culture=neutral,
PublicKeyToken=xxxxxxxxxxxxxxxx"
friendlyName="sampleLoggerWithoutParameters2" />
This loads and initializes:
Logger with friendlyName="sampleLoggerwithParameters". Key1=Value1 and Key2=Value2 are passed as dictionary parameters
to the logger while initialization. i.e.
SampleLoggerWithParameters.Initialize(TestLoggerEvents events,
Dictionary<string, string> parameters) is invoked with parameters =
{{"Key1", "Value1"}, {"Key2", "Value2"}}
Logger with uri="logger://sample/sampleLoggerWithoutParameters1". FriendlyName is ignored in this case as uri takes more precedence.
Logger with assemblyQualifiedName="Sample.Sample.Sample.SampleLogger,
Sample.Sample.Logger, Version=0.0.0.0, Culture=neutral,
PublicKeyToken=xxxxxxxxxxxxxxxx". Uri and friendlyName are ignored in
this case as assemblyQualifiedName takes more precedence.
I'd like to print a file containing listing of all the dependencies and their versions in my pom.xml. (no need to go inside of each dependency)
My ultimate goal is to have the dependency + version information listing in a file that can be read by the application at runtime and be displayed via "version info" link on a web page.
I found out there is a maven dependecy plugin | dependency:list, which I understand, should be doing pretty much what I want. I also manage it to print an output file, but it contains mainly gibberish. What I can make sense of it, it just has some kind of listing of the packages in the project. (no version info)
Could someone please clarify how to use this plugin correctly, or if it even does what I need it to do.
My configuration is same as in their usage instructions, but if try to use any optional parameters it fails always.
This looks like it is doing the right thing now. A version file is printed in 'target/classes' and I can find it when looking from the app at runtime.
In pom.xml (in build/plugins):
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
<executions>
<execution>
<id>createVersionInfo</id>
<phase>compile</phase>
<goals>
<goal>list</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com.company.project</groupId>
<artifactId>app-name</artifactId>
<version>${project.version}</version>
<type>war</type>
<overWrite>true</overWrite>
</artifactItem>
</artifactItems>
<sort>true</sort>
<includeScope>compile</includeScope>
<outputFile>target/classes/dependency_versions.txt</outputFile>
</configuration>
</execution>
</executions>
</plugin>
The '<excludeScope>test</excludeScope>' does not work as supposed. It excludes everything. I think the explanation for includeScope explains this somehow.
An Empty string indicates all scopes (default).
The scopes being interpreted are the scopes as Maven sees them,
not as specified in the pom. In summary:
runtime - scope gives runtime and compile dependencies,
compile - scope gives compile, provided, and system dependencies,
test - (default) scope gives all dependencies,
provided - scope just gives provided dependencies,
system - scope just gives system dependencies.
And this piece of code on the java side will do pretty much what is needed:
InputStream in = this.getClass().getResourceAsStream("/dependency_versions.txt"); // Finds the file from classpath
String content = "";
// Java7 AutoCloseable
try (Scanner scan = new Scanner(in)) {
scan.useDelimiter("\\Z"); // Found this from another SO-thread, enables to read in the whole file at once
content = scan.next();
}
// Iterate the content and collect the information
// \n = line change
for (String row : content.split("\n")) {
row = row.trim();
// Basically removes the 1st two lines of the file that are not wanted
if (StringUtils.isEmpty(row) || row.endsWith(":")) {
continue;
}
StringTokenizer tokenizer = new StringTokenizer(row, ":");
String package = tokenizer.nextToken();
String dependency = tokenizer.nextToken();
String type = tokenizer.nextToken();
String version = tokenizer.nextToken();
String scope = tokenizer.nextToken();
}
I am actually populating a list of my own TO's there for showing the info in JSF, but I omit that part for simplicity/readability.
... Actually made me think why do I want to read in the whole file at once and not iterate it and read it one row at a time, but I'll leave it for the daily WTF. ;)
My pom.xml contains the following to auto generate a client for a working web service having the WSDL specified below:
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>2.3.1</version>
<executions>
<execution>
<id>generate-sources</id>
<configuration>
<sourceRoot>${basedir}/target/generated/src/main/java</sourceRoot>
<wsdlOptions>
<wsdlOption>
<wsdl>${basedir}/src/main/wsdl/myclient.wsdl</wsdl>
<extraargs>
<extraarg>-client</extraarg>
<extraarg>-verbose</extraarg>
</extraargs>
<wsdlLocation>wsdl/myclient.wsdl</wsdlLocation>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
The project builds fine, without any errors or warnings and I can see the the file myclient.wsdl in the JAR file right under a wsdl folder.
But when I try running that JAR:
java -Xmx1028m -jar myclient-jar-with-dependencies.jar
It complains that "Can not initialize the default wsdl from wsdl/myclient.wsdl"
Why?
What am I missing?
How can I find out what path that wsdl/myclient.wsdl in pom.xml translates into, that makes the client's JAR complain at run time?
Update: I am aware of some solutions/workarounds that involve modifying the auto-generated code:
Pass "null" for the wsdl URL and then use the ((BindingProvider)port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://example.com/....") to set the address.
load the WSDL as a Java resource and pass its location into your service's constructor.
But I am more interested in a solution that requires entering the right values into the pom.xml like the classpath approach (but unfortunately classpath didn't work for me for some reason).
Any ideas what I should be typing there instead? Apparently this is a very simply case of figuring out the correct path rules for that particular plugin, but I am missing something and I don't know what it is.
The error comes from the static initializer of your generated service class (which is annotated by #WebServiceClient). It tries to load the wsdl file as resource. The generator uses the value which you have provided by the parameter wsdlLocation. You should leave away the "wsdl/" prefix:
<wsdlLocation>myclient.wsdl</wsdlLocation>
because the wsdl is located directly in the root of the classpath folder.
BTW: If you omit the parameter <wsdlLocation> the value of the param <wsdl> is used (which is not correct at runtime in your case, but would be correct if the provided URL would be a remote URL address, i.e. directly fetched from the webservice server).
BTW2: Your workaround 2 is in fact +/- what the generated code of the service class does if you use the parameterless constructor.
I notice the cfx examples use slightly different locations for sourceRoot, wsdl and wsdlLocation.
Remember that typically, files in src/main/resources are included in the produced artifact. In order for files in src/main/wsdl to be included, it needs to be added as a resource in the pom.xml:
<resources>
<resource>
<directory>src/main/wsdl</directory>
</resource>
</resources>
Tips:
Set the paths you suspect to known bad paths and see if you get the same error-message.
Unzip the produced *.jar-file(s) and check if the wsdl is included, and what the path is.
NAnt has two built-in properties, nant.onsuccess and nant.onfailure, for specifying tasks to run on success and failure respectively.
Is there an equivalent in Ant?
I don't think there's an ant equivalent but you could use trycatch (part of ant-contrib)
<trycatch>
<try>
<!-- Your code here -->
<!-- Success message -->
</try>
<catch>
<!-- Fail message -->
</catch>
</trycatch>
Hope this helps
Kev Jackson, gave a neat example of an exec-listener in
his presentation, =
http://people.apache.org/~kevj/ossummit/extending-ant.html,
the sources of the exec-listener are included
You're able to kick off specific tasks depending
on the build result after your build has finished.
<exec-listener onSuccess="true|false">
..
your stuff goes here
..
</exec-listener>
Although I've marked John McG as the answer (as it's what I've gone with), I've also discovered that it's also possible to build similar functionality using BuildListeners.