Jenkins JUnit Report multiple failures\errors - java

I build a function that create JUnit report format xml that Jenkins can read.
my problem is that when I report 2 or more failures \ errors, Jenkins shows just the first on.
Also I tried to gather all error to one detailed error but jenkins show it not clear.
my xml looks like:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<testsuite errors="0" failures="2" hostName="name" name="Reporter" tests="1" time="202.053" timeStamp="Sun Jul 15 07:38:13 UTC 2018">
<testcase classname="bla" name="fail1" time="105.704">
<failure message="failure1" type="">trace...</failure>
<failure message="failure2" type="">trace2...</failure>
</testcase>
</testsuite>
jenkins shows he first only.
On other side if I put all failures in one node looks like this (I build it):
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><testsuite errors="0" failures="2" hostName="name" name="Reporter" tests="1" time="202.053" timeStamp="Sun Jul 15 07:38:13 UTC 2018">
<testcase classname="bla" name="fail1" time="105.704">
<failure message=
"failure1
failure2
failure3
...
.."
type="">trace...</failure>
</testcase>
</testsuite>
all failures shown in on line without new line char.
can someone assist if there is a way to do it correctly?
Thanks,
Hezi

Related

“Time(3)” type on Liquibase with MySQL 8

I'm facing a problem using Liquibase with MySQL 8 where the following script is not putting the fraction part of type "time(3)", it only puts "time" on the type of the column. We run this script before with MySQL 5 and it worked fine.
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.16.xsd"
logicalFilePath="20220901.xml">
<changeSet author="MyUser" id="Change column 'time' to Datatype to milliseconds">
<modifyDataType
columnName="time"
newDataType="TIME(3)"
schemaName="${defaultSchema}"
tableName="table1"/>
<addNotNullConstraint
columnDataType="TIME(3)"
columnName="time"
schemaName="${defaultSchema}"
tableName="table1" />
</changeSet>
</databaseChangeLog>
I tried to update to most recent versions on maven dependencies of liquibase.core(to 4.16.1) and mysql-connector-java(to 8.0.30), the problem persists.
After multiple tests, i discover that the problem may be on liquibase generated query that not includes the fraction part "(3)", so as a workaround I used "modifySql" to change the query at the end.
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.16.xsd"
logicalFilePath="20220901.xml">
<!-- WORK-AROUND - Liquibase was generating a query with type 'TIME' instead of 'TIME(3)' so
we use 'REPLACE_WITH_TIME' as auxiliary type to replace all of it's occurrences in query
by 'TIME(3)' with 'modifySql'. -->
<changeSet author="MyUser"
id="Fix time column type to time(3) - 2022-10-06">
<modifyDataType columnName="time"
newDataType="REPLACE_WITH_TIME" schemaName="${defaultSchema}"
tableName="table1" />
<addNotNullConstraint columnDataType="REPLACE_WITH_TIME"
columnName="time" schemaName="${defaultSchema}"
tableName="table1" />
<modifySql>
<replace replace="REPLACE_WITH_TIME" with="TIME(3)" />
</modifySql>
</changeSet>
</databaseChangeLog>
It resolves the problem but its not the best solution.
So i wanted to ask if anybody noticed that and knows if its actally a liquibase bug or not.
Thanks in advance.

Quartz Scheduler, XML ValidationException

I'm trying to setup a Quartz Scheduler job using an XML file, the scheduler object is reading the .properties file and finds the XML job definition file.
however I am getting a parsing validation exception and I can't seem to be able to find what's wrong based on the error
11:14:12.314 [localhost-startStop-1] ERROR o.q.p.x.XMLSchedulingDataProcessorPlugin - Error scheduling jobs: Encountered 2 validation exceptions.
org.quartz.xml.ValidationException: Encountered 2 validation exceptions.
and then
Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'group'. One of '{"http://www.quartz-scheduler.org/xml/JobSchedulingData":durability, "http://www.quartz-scheduler.org/xml/JobSchedulingData":job-data-map}' is expected.
I have already defined <durability> and the job doesn't require a data map.
My XML is
<?xml version="1.0" encoding="UTF-8"?>
<job-scheduling-data
xmlns="http://www.quartz-scheduler.org/xml/JobSchedulingData"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.quartz-scheduler.org/xml/JobSchedulingData
http://www.quartz-scheduler.org/xml/job_scheduling_data_1_8.xsd"
version="1.8">
<schedule>
<job>
<name>MailJob</name>
<description>Mail dispatcher job</description>
<job-class>com.myapplication.reporting.MailJob</job-class>
<group>MailGroup</group>
<durability>false</durability>
</job>
<trigger>
<simple>
<name>MailTrigger</name>
<description>Mail dispatcher job trigger, this should be set to run every 1 minute</description>
<repeat-interval>60000</repeat-interval>
<group>MailTriggerGroup</group>
<job-name>MailJob</job-name>
<job-group>mailGroup</job-group>
</simple>
</trigger>
</schedule>
</job-scheduling-data>
I am using Quartz 2.2.2
I suppose the problem may be in the order in which you define nodes in your XML.
Try reorder them like here
I.e. name/group/description then other settings.
It appears the order of the XML elements is important for the parser, using the Netbeans XML validation feature I edited the XML file and it's now working fine
<?xml version="1.0" encoding="UTF-8"?>
<job-scheduling-data
xmlns="http://www.quartz-scheduler.org/xml/JobSchedulingData"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.quartz-scheduler.org/xml/JobSchedulingData
http://www.quartz-scheduler.org/xml/job_scheduling_data_1_8.xsd"
version="1.8">
<schedule>
<job>
<name>MailJob</name>
<group>MailGroup</group>
<description>Mail dispatcher job</description>
<job-class>com.myapplication.reporter.MailJob</job-class>
</job>
<trigger>
<simple>
<name>MailTrigger</name>
<description>Mail dispatcher job trigger, this should be set to run every 1 minute</description>
<job-name>MailJob</job-name>
<job-group>MailGroup</job-group>
<repeat-count>0</repeat-count>
<repeat-interval>60000</repeat-interval>
</simple>
</trigger>
</schedule>
</job-scheduling-data>

How to store timestamp in Maven Surefire generated report.xml?

Is there a way, to instruct Maven Surefire, to save the test starting time of each JUnit Test Case in the report xml file?
I expect that the report should look a bit like this:
<?xml version="1.0" encoding="UTF-8"?>
<testsuite name="com.chris.testcases.Timestamp" time="1,962.965" tests="1" errors="0" skipped="0" failures="0">
<properties>
<property ...>
</properties>
<testcase
name="Timestampfilter"
classname="com.chris.testcases.Timestamp"
time="1,339.383" <-- this is the already existing execution time
--> timestamp="2015-03-11 16:44:05" /> <-- this is the NEW attribute I need
...
</testsuite>
Background: I need this paramter for future processing in this xml, and just writing the timestamp in the "normal" logfile/output is no solution.
I am using: Maven 3.2.5 with Surefire-Plugin 2.18.1.
Update: I found an similar question here: https://jira.codehaus.org/browse/SUREFIRE-681

How to add a property into an xml?

I´ve a quartz-config file and I want to load my cron expression from my property file, here is the code:
<?xml version='1.0' encoding='utf-8'?>
<job-scheduling-data version="1.8"
xmlns="http://www.quartz-scheduler.org/xml/JobSchedulingData"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.quartz-scheduler.org/xml/JobSchedulingData http://www.quartz-scheduler.org/xml/job_scheduling_data_1_8.xsd">
<properties>
<property url="file:///C:/apps/Labels/resources/ftp.properties"></property>
</properties>
<schedule>
<job>
<name>DevolucionesShippingJob</name>
<group>DevolucionesShippingJob</group>
<description>Retrieve FTP jobs procesed files from BIDS</description>
<job-class>com.quartz.DevolucionesShippingJob</job-class>
</job>
<trigger>
<cron>
<name>DevolucionesShippingTrigger</name>
<group>DEFAULT</group>
<job-name>DevolucionesShippingJob</job-name>
<job-group>DevolucionesShippingJob</job-group>
<cron-expression>0 07 19 * * ?</cron-expression>
</cron>
</trigger>
</schedule>
</job-scheduling-data>
The problem is that the eclipse parse marks an error in the line that has
How can I import a property file into my xml?
Thanks in advance.
It has been a while since I used Quartz but I do not recall seeing this done before. Also, if I'm looking at the referenced schema correctly, the properties element is not valid (hence Eclipse showing an error). In short, I don't think you can do this.

Does the JUnit XML format really not have an error element?

Looking at the informal spec at from this question, I notice that there is no element for errors. Is that just an oversight? CruiseControl seems to extract errors from somewhere.
<testsuites>
<testsuite name="name" errors="1" failures="0">
<testcase name="name">
<error>Some error message</error>
</testcase>
</testsuite>
</testsuites>
You can view this article. The modified sample from this article:
<target name="test">
<junit printsummary="withOutAndErr" fork="off" haltonfailure="no">
<classpath refid="classpath.test"/>
<formatter type="brief" usefile="false"/>
<test name="packagename.MyTest"/>
</junit>
</target>
You can see all messages from junit tests in console (or in report file)
You can read about printsummary, haltonfailure properties and the other ones at the ant site.
The other useful link.
I know it's been a while, but, there is an element for errors, and you can distinguish between errors and failures:
<?xml version="1.0" encoding="utf-8"?>
<testsuites errors="1" failures="2" tests="5" time="10">
<testsuite errors="1" failures="2" id="0" name="TestSuite1" tests="4" timestamp="2015-04-20T00:00:00">
<testcase classname="ModuleIAmTesting" name="testDoNothingDoesNothing" time="1"/>
<testcase classname="ModuleIAmTesting" name="testLongThingTakesALongTime" time="5"/>
<testcase classname="ModuleIAmTesting" name="testSkyIsBlue" time="1">
<failure message="Test testSkyIsBlue() failed!" type="failure">
It's storming; sky is gray today. Failure output, details, etc.
</failure>
</testcase>
<testcase classname="ModuleIAmTesting" name="testIsNotStorming" time="1">
<failure message="Test testIsNotStorming() failed!" type="failure">
Another failure. Failure output, details, etc.
</failure>
</testcase>
<testcase classname="ModuleIAmTesting" name="testCreatePlugin" time="2">
<error message="Error while executing test testCreatePlugin()!" type="error">
Unhandled catastrophic exception in ModuleIAmTesting.cpp at like 4420, details, etc.
</error>
</testcase>
</testsuite>
</testsuites>
The important part is the <error> tag and the errors attribute to <testsuite>.

Categories

Resources