Create job for every testsuite using job dsl - jenkins-job-dsl

I'm using TestNG, Jenkins, and the job-dsl-plugin.
I have a lot of TestNG XML testsuites for the tests in my project. What I want is a script that will go through each of these suites and create a job for them.
My test suites are formatted like this:
<suite name="Name of Suite">
<test name="Name of Test">
<packages>
<package name="package.to.test.*"/>
</packages>
</test>
</suite>
So the job DSL script would have to recursively go through each of the tests in my testsuites directory, grab and parse the XML of these files, and then create a job for each one of them.
Visit repo
Recursively read every XML file in testsuites directory
Grab the name of the suite -> name of Jenkins job
Grab the path to this testsuite -> -Dtestngfile=<path>
Create a job for each of these

Related

Running all test with PHPUnit in Symfony

I'm using PHPUnit 5.4.8 and Symfony 2.3
I have all my bundles with unit tests and I would like to run all those tests, with coverage in html. I tried with the command
phpunit -c app --no-globals-backup --coverage-html ~/coverage/ src/*Bundles/Tests/Unit
But it just doesn't work.
This is my test suite in phpunit.xml.dist
<testsuites>
<testsuite name="Project Test Suite">
<directory>../src/*/*Bundle/Tests/Unit</directory>
</testsuite>
</testsuites>
I figure out how to do it, first the name of the test suite can't have blank spaces, so phpunit.xml.dist file is this now:
<testsuites>
<testsuite name="Project">
<directory>../src/*/*Bundle/Tests/Unit</directory>
</testsuite>
</testsuites>
And you run the test suite with command:
phpunit -c app --no-globals-backup --coverage-html ~/coverage/ --testsuite Project

Jenkins tests reports analyzer integration with catch

I've recently started working with Jenkins to automatically build my c++ project and run my tests (I'm using catch.cpp).
I wanted some sort of a table of test run time and status and that led me to the "Test Results Analyzer" Plugin for Jenkins.
I have my builds run like this:
And you can see they actually run in the console output:
finally, my test results analyzer plugin shows nothing:
It looks like the plugin does not recognize that these are my tests. Which is reasonable since I've only told jenkins to execute these commands and i don't think it's smart enough to understand these are the tests to report. But i could not find how to tell "Test Reports Analyzer" what are the tests it needs to report.
My question is how do i get a table of tests like in the Plugins webpage:
Tests Reports Analyzer
Solution:
Jenkins needs a Junit format xml file of the test results.
specifically, in Catch.cpp this is achieved by the "-r junit" command line option.
after this i needed to configure jenkins to "Publish JUnit test result report" post-build action and git it a path to the output xml file i create with my "make test" command.
Solution provided by OP:
Jenkins needs a Junit format xml file of the test results.
specifically, in Catch.cpp this is achieved by the "-r junit" command line option.
after this i needed to configure jenkins to "Publish JUnit test result report" post-build action and git it a path to the output xml file i create with my "make test" command.

Running the Unit test cases in solr using ant

I am trying to run my test cases in solr using ant. Below is the ant command I am using:
ant test –Dtestcase=<test case name> test -Dtests.leaveTemporary=true
Now I have my own customized solrconfig & schema, so running above command builds the project again & overrites my customized solrconfig & schema.
Kindly help me with this.
You can use the method:
initCore(String config, String schema, String solrHome) of class SolrTestCaseJ4.java in your TestCase and pass the path of your customized schema and config as your solrHome(typical format: solr\collection1\conf).

run all zend framework2 unit tests

I'm trying to get a project build setup in Jenkins for Zend Framework 2, I want to run all the unit tests for each of the modules I am writing - but I'm a lil unclear how to do this?
Each module has its own 'test' directory and I can run each modules test suite just fine. Do I have to write some script to find all custom modules and run their tests? Does anyone have a good example how to do this?
First, get the test to run together
I would try writing a new phpunit config file, say all.xml, giving the details of the different test files.
<phpunit>
<testsuite name="Module1">
<directory>./module1</directory>
</testsuite>
<testsuite name="Module2">
<directory>./module2</directory>
</testsuite>
<testsuite name="Module2">
<directory>./module3</directory>
</testsuite>
</phpunit>
Test that this runs ok on the command line
$ phpunit -c all.xml
Add to Jenkins
Just add this into you Jenkins config. Here is an example if you use an Ant xml file:
<target name="phpunit" description="Run unit tests with PHPUnit">
<exec executable="phpunit" failonerror="true">
<arg line=" -c tests/all.xml" />
</exec>
</target>

JWSC ant task with <module> element's explode attribute set to true

I'm using WebLogic JWSC ant task to generate WebLogic Web Service artifacts from existing wsdl. JWSC generates all the required files and archives them in an ear file.
Since I don't want JWSC task to create a new application.xml, I use applicationXml attribute of the JWSC task by pointing the location of the existing application.xml. Then JWSC task updates the application.xml by adding a new <module> tag successfully. Inside the module tag there is <web-uri> tag. web-uri defines the location of the WAR file. So far so good.
If I set explode attribute to true, the task doesn't create an ear file, put all the required files inside a directory. JWSC task also update the specified application.xml too, but this time it puts the exloded directory's name to web-uri tag without the .war extension altough it is wrong to put here a non war file name.
The correct format should be like that
<module>
<web>
<web-uri>petStore.war</web-uri>
<context-root>store</context-root>
</web>
</module>
If you don't realize the situation, WebLogic will not find the specified war file (without .war extension)
Does anyone know why JWSC updates the application.xml with a wrong web-uri ?
We can have the application.xml some where , when we create an app.xml we will give property appxml = "${path-original-application.xml}" below is the snippet
<target name="dist-ear" depends="clean-build-webservices">
<delete file="${build.dir}/META-INF/application.xml"/>
<copy todir="${build.dir}/META-INF" overwrite="true">
<fileset dir="${webservices.resource.dir}">
<include name="weblogic-application.xml"/>
</fileset>
</copy>
<ear destfile="${dist.dir}/${webservice.name}.ear" appxml="${viwebservices.appxml.location}">
<fileset dir="${build.dir}" includes="*.war"/>
<zipfileset dir="${webservices.src.dir}/jdbc" prefix="jdbc"/>
<metainf dir="${build.dir}/META-INF"/>
</ear>
</target>