I've just migrated to JUnit 5 and I can't see any test cases in the XML test reports for my test suites. I've written my test suites in the new JUnit 5 syntax for junit-platform-suite and the tests in my suites all run successfully.
This generates JUnit XML reports via Surefire. One XML file is generated for each test class, plus one for the suite. The XML file for the suite has no <testcase> elements in it and shows that no tests have been run, even though they have.
Does anyone know why this might be? Are there perhaps some differences in XML reporting in JUnit 5?
Test suite class:
#Suite
#SelectClasses({ LoggedOutSupportPageTest.class,
LoggedInSupportPageTest.class
})
public class SingleTestSuite {
}
JUnit suite XML report structure:
<?xml version="1.0" encoding="UTF-8"?>
<testsuite xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://maven.apache.org/surefire/maven-surefire-plugin/xsd/surefire-test-report-3.0.xsd" version="3.0" name="com.myorganisation.suites.SingleTestSuite" time="17.231" tests="0" errors="0" skipped="0" failures="0">
<properties>
lots of properties are here
</properties>
</testsuite>
Related
Im currently using QAF at my job and recently setup a few CICD tests using Azure Devops.
Azure Devops at the moment is only designed to read to Junit .XML results in their reporting dasbboard.
When running a Maven test, TestNG automatically creates a JunitReports folder that has a .xml report in it.
The issue is that when using QAF and using BDDStepFactory2 in my config.xml file, my junit report shows all tests as ignored.
Is there a way I can continue using BDDStepFactory2 and get the Junitresults to show either pass or fails?
EDIT:
The JunitResult is generating, however, this is what it looks like
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated by org.testng.reporters.JUnitReportReporter -->
<testsuite skipped="2" hostname=
name="com.qmetry.qaf.automation.step.client.DataDrivenScenario" tests="4" failures="0" timestamp="2021-12-27T16:21:34 EST" time="12.916" errors="0">
<testcase name="Validate the Home Page" time="7.287" classname="com.qmetry.qaf.automation.step.client.DataDrivenScenario"/>
<system-out/>
<testcase name="Validate the Home Page" time="5.629" classname="com.qmetry.qaf.automation.step.client.DataDrivenScenario"/>
<system-out/>
<testcase name="scenario" classname="com.qmetry.qaf.automation.step.client.DataDrivenScenario">
<skipped/>
</testcase> <!-- scenario -->
<system-out/>
<testcase name="scenario" classname="com.qmetry.qaf.automation.step.client.DataDrivenScenario">
<skipped/>
</testcase> <!-- scenario -->
<system-out/>
</testsuite> <!-- com.qmetry.qaf.automation.step.client.DataDrivenScenario-> ```
At the top, the xml is showing skipped="2". Since this is what Azure devops is reading, it is seeming like two of my tests have been skipped.
Most probably issue with TestNG version. Try latest (7.4.0) version of TestNG with latest (3.1.0-RC1) version of QAF.
<dependency>
<groupId>com.qmetry</groupId>
<artifactId>qaf</artifactId>
<version>3.1.0-RC1</version>
</dependency>
<!-- order is important -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.4.0</version>
</dependency>
In order to write step information in junit report (just like testng reporter output) enable testng output by setting property.
report.log.testngoutput=true
Check your test-results directory, You may find junit report for each execution. For instance <project-root>\test-results\<timestamp>\junitreports. In case you don't found junit reports generated, you can enable testng default listeners.
I want to pass an XML to jenkins ,which will have more than junit available elements, in order to show results.
junit available elements are:
<testsuites>
<testsuite>
<testcase/>
</testsuite>
<testsuties>
But what if i want to pass:
<testsuites>
<testsuite>
<testcases>
<testcase>
<subtestcase/>
</testcase>
</testcases>
</testsuite>
<testsuties>
As part of a testng automation test suite I would like to automatically push results from jenkins to testrail. I currently have this plugin installed on my jenkins server: https://github.com/jenkinsci/testrail-plugin
The read me states the output must comply with the junit schema: https://github.com/windyroad/JUnit-Schema/blob/master/JUnit.xsd
I have reference How do I get one junit report from TestNG for all my test cases? and added
<listeners>
<listener class-name="org.testng.reporters.JUnitXMLReporter"></listener>
</listeners>
to my listeners; however, this does not seem to create a file in the correct format as this causes jenkins to fail with the message :
Uploading results to TestRail.
Error pushing results to TestRail
Posting to index.php?/api/v2/add_results_for_cases/236 returned an error! Response from TestRail is:
{"error":"Field :results cannot be empty (one result is required)"}
Build step 'TestRail Plugin' marked build as failure
Finished: FAILURE
I am wondering if there is a different listener I should be using instead.
Thank you for the help.
I used the xsd file that was shared in the question to create a TestNG reporter that complies with the xsd.
To consume this reporter, please add a dependency as below
<dependency>
<groupId>com.rationaleemotions</groupId>
<artifactId>junitreport</artifactId>
<version>1.0.0</version>
</dependency>
This reporter makes use of the service loader approach to wire in itself. So it doesn't need to be added explicitly via the <listeners> tag (or) the #Listeners annotation.
Details can be found here
We have one xml configuration file that we use in production. We also have a little test app that has a couple of additional needs. What I'd like to do is create a second, testing-only xml config file that references the embedded production configuration file. Is there any way to do this?
I'm aware of the "include" element, but am not sure where in the file it is supposed to be placed--in the castle node? The components node?
I feel like the answer is here but I'm too dense to figure it out.
Thanks for any help you can provide.
UPDATE
This is how our production config file is set up:
<?xml version="1.0" encoding="utf-8"?>
<OurCompany>
<Framework>
<castle>
<installers>
<!-- some installers-->
<installers>
<components>
<!--some components-->
<components>
<castle>
<Framework>
<OurCompany>
My most recent attempt at a non-production config file looks like this:
<?xml version="1.0" encoding="utf-8"?>
<OurCompany>
<Framework>
<castle>
<include uri="assembly://AssemblyContainingEmbeddedXml/MyEmbeddedConfig.xml" />
<components>
<!--components I only want registered with container when running in non-production environment-->
<components>
<castle>
<Framework>
<OurCompany>
The exception I get reads:
Configuration parser encountered Framework, but it was expecting to find installers, facilities or components. There might be either a typo on or you might have forgotten to nest it properly.
(In the actual message, "Framework," "installers," "facilities," and "components" are enclosed in angle brackets.)
The bottom of the page you reference has an example of loading from an embedded resourced:
IResource resource = new AssemblyResource("assembly://Acme.Crm.Data/Configuration/services.xml");
container = new WindsorContainer(new XmlInterpreter(resource));
I had webapps using spring jdbc template and now , want to improve performance of my application , so i want to cache result of some DATABASE QUERY in my Tomcat server.How i can achieve dis concept.
Thanks
Spring 3.1 has introduced a Caching Abstraction. You should be able to make use of this to cache the results of your DAO method calls.
The documentation is here and it was included in the Spring blog here.
I have it working, but Alex is correct, there are a few different ways to configure this, depending on what you want as your Caching backend.
For cache configuration, I've selected ehcache, as it's simple to configure, but has powerful features for configuring ttl/etc.
Configuration:
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.springframework.org/schema/beans"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:cache="http://www.springframework.org/schema/cache"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache.xsd">
<cache:annotation-driven />
<bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager">
<property name="cacheManager"><ref local="ehcache"/></property>
</bean>
<bean id="ehcache" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"
p:configLocation="classpath:ehcache.xml"/>
</beans>
ehcache.xml:
<?xml version="1.0" encoding="UTF-8"?>
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd"
updateCheck="false" monitoring="autodetect"
dynamicConfig="true">
<!-- http://ehcache.org/documentation/configuration.html -->
<!-- Also See org.springframework.cache.ehcache.EhCacheFactoryBean -->
<diskStore path="java.io.tmpdir"/>
<cache name="resourceBundle"
overflowToDisk="false"
eternal="false"
maxElementsInMemory="500"
timeToIdleSeconds="86400"
timeToLiveSeconds="86400"/>
</ehcache>
I had issues with running the ehcache 2.5 in my junit environment, due to caches with duplicate names running concurrently was not allowed, and they didn't seem to shut down right away, but here is my pom entry:
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache-core</artifactId>
<version>2.4.7</version>
</dependency>
Finally, on your repository, do the following:
#Repository
public class someStore {
#PersistenceContext
EntityManager em;
//The value here needs to match the name of the cache configured in your ehcache xml. You can also use Spel expressions in your key
#Cachable(value = "resourceBundle", key = "#basename+':'+#locale.toString()")
public ResourceBundle getResourceBundle(final String basename, final Locale locale){
...
}
#CacheEvict(value = "resourceBundle", key = "#basename+':'+#locale.toString()")
public void revertResourceBundle(final String basename, final Locale locale){
...
}
}