XUnit TestResult in Jenkins doesnt show Testnames - jenkins

Here is the Test Result Jenkins shows me. The names are empty.
But in the XML, that was generated and loaded in the Post Build from Jenkins, the test names are shown and correct:
<?xml version="1.0" encoding="utf-8"?>
<assemblies>
<assembly name="xyz" environment="32-bit .NET 4.0.30319.42000 [collection-per-class, parallel (8 threads)]" test-framework="xUnit.net 2.1.0.3179" run-date="2016-02-29" run-time="10:17:15" config-file="xyz" total="4" passed="2" failed="0" skipped="2" time="46.081" errors="0">
<errors />
<collection total="4" passed="2" failed="0" skipped="2" name="xyz" time="45.641">
<test name="CashFactorSetInValidValues" type="XUnit_DataManager_Tests.DataManagerGuiGeneral" method="CashFactorSetInValidValues" time="22.7359448" result="Pass">
<traits>
<trait name="DataManager" value="General" />
<trait name="General" value="CashFactor" />
</traits>
</test>
<test name="TestCurrencySetAll" type="XUnit_DataManager_Tests.DataManagerGuiGeneral" method="TestCurrencySetAll" time="0" result="Skip">
<traits>
<trait name="DataManager" value="General" />
<trait name="General" value="Currency" />
</traits>
<reason><![CDATA[Eine Ausnahme vom Typ "Xunit.SkipException" wurde ausgelöst.]]></reason>
</test>
<test name="TestCurrencyAllAvailable" type="XUnit_DataManager_Tests.DataManagerGuiGeneral" method="TestCurrencyAllAvailable" time="0" result="Skip">
<traits>
<trait name="DataManager" value="General" />
<trait name="General" value="Currency" />
</traits>
<reason><![CDATA[Eine Ausnahme vom Typ "Xunit.SkipException" wurde ausgelöst.]]></reason>
</test>
<test name="CashfactorSetValidValues" type="XUnit_DataManager_Tests.DataManagerGuiGeneral" method="CashfactorSetValidValues" time="14.8607297" result="Pass">
<traits>
<trait name="DataManager" value="General" />
<trait name="General" value="CashFactor" />
</traits>
</test>
</collection>
</assembly>
</assemblies>
I am using the new XUnit Function [SkippableFact] and 2 of the Tests I skipped. The Result.xml is ok and shows exactly what happened, but it can't be interpreted as it seems.
EDIT: I tested it without the SkippableFact and it still doesn't work.

Related

Unable to run parallel tests with Selenium Grid(Appium) in Android?

I want to execute test script on multiple devices(Android). when i run my java class with JUnit i am able to execute in only one device. How to execute in multiple devices at a time.
Any suggestion would be appreciated.
TestNG.xml file
<suite name="Default suite" thread-count="2" parallel="tests">
<test name="Nexus">
<Parameters>
<parameter name="platform" value="Nexus"/>
<parameter name="browsername" value="Android"/>
<parameter name="udid" value="xyz" />
<parameter name="remoteurl" value="http://0.0.0.0:4723/wd/hub"/>
</Parameters>
<classes>
<class name="AppiumTest">
<methods>
<include name="Test1"/>
<include name="Test2"/>
<include name="Test3"/>
</methods>
</class>
</classes>
</test>
<test name="Moto E">
<Parameters>
<parameter name="platform" value="Moto E"/>
<parameter name="browsername" value="Android"/>
<parameter name="udid" value="abc" />
<parameter name="remoteurl" value="http://0.0.0.0:4726/wd/hub"/>
</Parameters>
<classes>
<class name="AppiumTest">
<methods>
<include name="Test1"/>
<include name="Test2"/>
<include name="Test3"/>
</methods>
</class>
</classes></suite>
If you use testNG instead of JUnit you can create a test suite with a testng.xml file that should look like this:
<?xml version="1.0" encoding="UTF-8"?>
<suite name="Suite" parallel="tests" thread-count="2">
<test name="Nexus 7">
<parameter name="udid" value="XXXX" />
<classes>
<class name="testNG.TestOne"/>
</classes>
</test> <!-- Test -->
<test name="HTC desrire">
<parameter name="udid" value="XXXX" />
<classes>
<class name="testNG.TestOne"/>
</classes>
</test> <!-- Test -->
</suite> <!-- Suite -->
Stating parallel tests and a thread-count of 2 allows two tests to be completed on seperate devices in parallel.
All you need to do from here is configure Selenium Grid nodes with capabilities of each device and in your tests script use the udid parameter passed in through the testng.xml.
Hope this helps.
Just launch another test after the first is launched. Of course each test must be pointed to different device.
Try to apply the concept shown in the below thread.It is using grid concept in selenium to start two appium sessions in parallel.By this we can run our scripts parallely on two android devices.
https://discuss.appium.io/t/connecting-appium-server-to-selenium-grid-for-android/804/10

Parse test name from testng xml to ant build.xml

There are many testng.xml files which I run via same build.xml using command line option.
I want build.xml to parse the test name from each testng.xml that is passed via command line option
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="tests" verbose="1" threads="10" preserve-order="true">
<test name="first" preserve-order="true">
<classes>
<class name="com.etc.first">
<methods>
<include name="First" />
</methods>
</class>
</classes>
</test>
<test name="second" preserve-order="true">
<classes>
<class name="com.etc.Second.java">
<methods>
<include name="Req" />
</methods>
</class>
</classes>
</test>
</suite>

NLog not writing to Database Target

Having trouble getting the database target for NLog to work. I have 2 targets: FILE and DB.. here is my NLog.config:
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
autoReload="true"
throwExceptions="false">
<variable name="appName" value="KoreCMS" />
<targets async="true">
<target xsi:type="File"
name="default"
layout="${longdate} - ${level:uppercase=true}: ${message}${onexception:${newline}EXCEPTION\: ${exception:format=ToString}}"
fileName="${basedir}\App_Data\Log\Debug.log"
keepFileOpen="false"
archiveFileName="${basedir}\App_Data\Log\Debug_${shortdate}.{##}.log"
archiveNumbering="Sequence"
archiveEvery="Day"
maxArchiveFiles="30"/>
<target xsi:type="Database"
name="database"
keepConnection="true"
useTransactions="true"
dbProvider="System.Data.SqlClient"
connectionStringName="DefaultConnection"
commandText="INSERT INTO Kore_Log(EventDateTime, EventLevel, UserName, MachineName, EventMessage, ErrorSource, ErrorClass, ErrorMethod, ErrorMessage, InnerErrorMessage) VALUES (#EventDateTime, #EventLevel, #UserName, #MachineName, #EventMessage, #ErrorSource, #ErrorClass, #ErrorMethod, #ErrorMessage, #InnerErrorMessage)">
<parameter name="#EventDateTime" layout="${date:s}" />
<parameter name="#EventLevel" layout="${level}" />
<parameter name="#UserName" layout="${aspnet-user-identity}" />
<parameter name="#MachineName" layout="${machinename}" />
<parameter name="#EventMessage" layout="${message}" />
<parameter name="#ErrorSource" layout="${event-context:item=error-source}" />
<parameter name="#ErrorClass" layout="${event-context:item=error-class}" />
<parameter name="#ErrorMethod" layout="${event-context:item=error-method}" />
<parameter name="#ErrorMessage" layout="${event-context:item=error-message}" />
<parameter name="#InnerErrorMessage" layout="${event-context:item=inner-error-message}" />
</target>
</targets>
<rules>
<logger name="*" writeTo="default" minlevel="Info" />
<logger name="*" writeTo="database" minlevel="Info" />
</rules>
</nlog>
And here is the DB design:
And here is the connection string:
<connectionStrings>
<add name="DefaultConnection" connectionString="Server=.\SQLExpress2012;Initial Catalog=MyDatabaseName;Integrated Security=True;Persist Security Info=True;MultipleActiveResultSets=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
What am I missing?
Alright, I figured it out... When I opened up SQL Profiler, I could see the INSERT command was indeed being sent, so I attempted to run the same command myself manually and discovered that I was being an idiot; basically, my Id column is setup as a uniqueidentifier and so of course it could not be auto incremented. The solution was to change the commandText in the Nlog.config to the following:
commandText="INSERT INTO Kore_Log(Id, EventDateTime, EventLevel, UserName, MachineName, EventMessage, ErrorSource, ErrorClass, ErrorMethod, ErrorMessage, InnerErrorMessage) VALUES (NEWID(), #EventDateTime, #EventLevel, #UserName, #MachineName, #EventMessage, #ErrorSource, #ErrorClass, #ErrorMethod, #ErrorMessage, #InnerErrorMessage)">
I got into same problem, reason was dbProvider value and connectionStringName key in nlog.config. I got it from here
<target name="database" xsi:type="Database" connectionString="${configsetting:name=sqlconnection.connectionString}"
dbProvider="Microsoft.Data.SqlClient.SqlConnection, Microsoft.Data.SqlClient">
Also,
connectionString should be used in place of connectionStringName
if Microsoft.Data.SqlClient is not added in dependency, it need to be added either using nuget package manager or manually.

No Unit Test Statistics Displayed in Sonar even when Test Coverage is displayed

We are using ant for our build process. We wanted to get the test coverage for our project. So we integrated jacoco with sonar to perform the test coverage.
The test Coverage is displayed correctly but the Unit Test Statistics are not displayed at all.
After searching in various forums we saw that it might be related with the sonar.tests/sonar.binaries/sonar.junit.reportsPath configuration.
But even after making all these changes we are still not able to see the Unit Test Statistics in Sonar.
We are using,
Sonar Qube 4.5.2
Sonar Ant 2.2
Jacoco 0.7.2.201409121644
Please Assist.
-build.xml
<taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml" >
<classpath path="${jacoco_path}/lib/jacocoant.jar" />
</taskdef>
<target name="testCoverage" depends = "triv.build.all" description="Run unit tests and code coverage reporting">
<jacoco:coverage destfile="${CB_dirsrc}/reports/jacoco.exec" xmlns:jacoco="antlib:org.jacoco.ant">
<junit haltonfailure="no" fork="true" printsummary="true" failureproperty="junitsFailed" errorProperty="junitsFailed" forkmode ="once">
<jvmarg value="-XX:MaxPermSize=512m"/>
<jvmarg value="-Xmx1024m"/>
<jvmarg value="-Xms1024m"/>
<classpath>
<path refid="test.classpath"/>
<path refid="core.classpath"/>
<pathelement path="${test.classes.dir}/classes"/>
</classpath>
<!--<formatter type="plain" usefile="false" />-->
<formatter type="xml"/>
<batchtest fork="yes" todir="${CB_dirsrc}/reports/junit">
<fileset dir="${test.src.dir}">
<!--<include name="**/*Test*.java"/>-->
<include name="**/*BasicTests.java"/>
<!--<exclude name="**/*BasicTests.java"/>-->
<exclude name="**/*TICPTestHook.java"/>
<exclude name="**/*TRIVTestCase.java"/>
<exclude name="**/*TestContext.java"/>
</fileset>
</batchtest>
</junit >
</jacoco:coverage>
</target>
<target name="report" depends ="testCoverage">
<!--<target name="report">-->
<!-- Step 3: Create coverage report -->
<jacoco:report xmlns:jacoco="antlib:org.jacoco.ant">
<!-- This task needs the collected execution data and ... -->
<executiondata>
<file file="${CB_dirsrc}/reports/jacoco.exec"/>
</executiondata>
<!-- the class files and optional source files ... -->
<structure name="JaCoCo Ant MPS Test">
<classfiles>
<fileset dir="${test.classes.dir}/classes" >
<!--<include name="**/*Test*.class"/>-->
<include name="**/*BasicTests.class"/>
<!--<exclude name="**/*BasicTests.class"/>-->
<exclude name="**/*TICPTestHook.class"/>
<exclude name="**/*TRIVTestCase.class"/>
<exclude name="**/*TestContext.class"/>
</fileset>
</classfiles><sourcefiles encoding="UTF-8">
<fileset dir="${test.src.dir}">
<!--<include name="**/*Test*.java"/>-->
<include name="**/*BasicTests.java"/>
<!--<exclude name="**/*BasicTests.java"/>-->
<exclude name="**/*TICPTestHook.java"/>
<exclude name="**/*TRIVTestCase.java"/>
<exclude name="**/*TestContext.java"/>
</fileset>
</sourcefiles>
</structure>
<!-- to produce reports in different formats. -->
<html destdir="${CB_dirsrc}/reports/jacoco"/>
<csv destfile="${CB_dirsrc}/reports/jacoco/report.csv"/>
<xml destfile="${CB_dirsrc}/reports/jacoco/report.xml"/>
</jacoco:report>
</target>
<!-- SONAR-->
<taskdef uri="antlib:org.sonar.ant" resource="org/sonar/ant/antlib.xml">
<classpath path="${sonar_ant_path}/sonar-ant-task-2.2.jar" />
</taskdef>
<target name="analyse" depends="report,init-sonar, sonar-java" description="Perform clean,build,testCoverage and sonar" >
<!--depends="triv.build.all,report,init-sonar, sonar-java"-->
<echo message="This task will do job of executing triv.clean, triv.build.all,testCoverage, init-sonar, sonar-java"/>
</target>
<target name="init-sonar">
<delete dir="${CB_dirsrc}/build/.sonar" />
<!-- MYSQL SONAR DB -->
<property name="sonar.jdbc.url" value="${CB_sonar_db_url_value}" />
<!-- <property name="${CB_sonar_db_driverClassName}" value="${CB_sonar_db_driverClassName_value}" /> -->
<property name="sonar.jdbc.username" value="${CB_sonar_db_username_value}" />
<property name="sonar.jdbc.password" value="${CB_sonar_db_password_value}" />
<!-- SONAR SERVER HOST -->
<property name="sonar.host.url" value="${CB_sonar_host_url}" />
<!-- SONAR PROJECT NAME -->
<property name="sonar.projectName" value="${CB_prd_longname}" />
<property name="sonar.projectKey" value="${CB_sonar_softwareId}" />
<property name="sonar.projectVersion" value="${CB_sonar_project_version}" />
<property name="sonar.sources" value="${CB_sonar_sources}" />
<property name="sonar.tests" value="${test.src.dir}" />
<property name="sonar.verbose" value="true" />
<property name="sonar.dynamicAnalysis" value="reuseReports" />
<property name="sonar.junit.reportsPath" value="${CB_dirsrc}/reports/junit" />
<property name="sonar.surefire.reportsPath" value="${CB_dirsrc}/reports/junit" />
<property name="sonar.java.coveragePlugin" value="jacoco" />
<!--<property name="sonar.java.codeCoveragePlugin" value="jacoco" />-->
<property name="reports.dir" value="${CB_dirsrc}/reports" />
<property name="sonar.jacoco.reportPath" value="${CB_dirsrc}/reports/jacoco.exec" />
<property name="sonar.binaries" value="target/classes" />
<property name="sonar.sourceEncoding" value="UTF-8" />
<property name="sonar.javascript.jstestdriver.reportsPath" value="${CB_dirsrc}/reports/junit" />
<property name="jpos.sonar.projectBaseDir" value="jpos/jpos" />
<property name="jpos.sonar.projectName" value="jpos" />
<property name="jpos.sonar.binaries" value="" />
<property name="audit.sonar.projectName" value="audit" />
<property name="callback.client.sonar.projectName" value="callback client" />
<property name="callback.server.sonar.projectName" value="callback server" />
<property name="consumerapp.sonar.projectName" value="consumerapp" />
<property name="core.sonar.projectName" value="core" />
<property name="external.sonar.projectName" value="external" />
<property name="facade.sonar.projectName" value="facade" />
<property name="facade.bank.sonar.projectName" value="facade bank" />
<property name="facade.citi.sonar.projectName" value="facade citi" />
<property name="facade.ssp.sonar.projectName" value="facade ssp" />
<property name="facade.switch.sonar.projectName" value="facade switch" />
<property name="facade.web.sonar.projectName" value="facade web" />
<property name="openapi.sonar.projectName" value="openapi" />
<property name="product.sonar.projectName" value="product" />
<property name="services.sonar.projectName" value="services" />
<property name="simulator.incoming.sonar.projectName" value="simulator incoming" />
<property name="simulator.incoming.sonar.binaries" value="" />
<property name="simulator.outgoing.sonar.projectName" value="simulator outgoing" />
<property name="simulator.outgoing.sonar.binaries" value="" />
<property name="svmas.sonar.projectName" value="svams" />
<property name="test.sonar.projectName" value="test" />
<property name="test.sonar.binaries" value="target/classes" />
<property name="ui.sonar.projectName" value="ui" />
<property name="ui.csc.sonar.projectName" value="ui csc" />
<property name="ui.msc.sonar.projectName" value="ui msc" />
<property name="ui.occ.sonar.projectName" value="ui occ" />
<property name="ui.purchase.sonar.projectName" value="ui purchase" />
<property name="util.sonar.projectName" value="util" />
<property name="sonar.my.property" value="value" />
</target>
<target name="sonar-java">
<property name="sonar.modules" value="${CB_sonar_java_modules_list}" />
<property name="sonar.language" value="java" />
<property name="sonar.branch" value="Java" />
<!--<property name="sonar.profile" value="${CB_sonar_java_profile}" />-->
<property name="sonar.libraries" value="${CB_sonar_libraries_list}" />
<!-- <sonar:sonar key="${CB_sonar_softwareId}" version="${CB_prd_shortversion}" xmlns:sonar="antlib:org.sonar.ant"/>-->
<sonar:sonar xmlns:sonar="antlib:org.sonar.ant"/>
</target>

How to append response message to a text file?

I need write the response message to a "response.xml" file. And the response should be appended to this file, I set parameter "Append" true, but no use, is completely overwritten every time. Anyone can help me? Thanks and best regards.
<proxy xmlns="http://ws.apache.org/ns/synapse" name="EndpointTest" transports="https,http" statistics="disable" trace="disable" startOnLoad="true">
<target>
<inSequence>
<log level="full" />
</inSequence>
<outSequence>
<log level="full" />
<send>
<endpoint>
<address uri="vfs:file:///usr/local/wso2esb-4.0.3/Log" format="pox" />
<property name="OUT_ONLY" value="true" />
<property name="transport.vfs.Append" value="true" />
<property name="transport.vfs.ReplyFileName" value="response.xml" />
</endpoint>
</send>
<send />
</outSequence>
<endpoint>
<address uri="http://172.21.13.151:18989/aaadc/services/receiveMsg" format="pox" />
</endpoint>
</target>
</proxy>
Remove the append= true parameter from service level and use with endpoint url
eg:
vfs:file:///usr/local/wso2esb-4.0.3/Log?transport.vfs.Append=true

Resources