Posting JUnit reports to Slack - junit

Is there any way we can post JUnit results **/TEST-*.xml to Slack. I have tried all possible ways but couldn't able to solve the issue.

JUnit itself cannot do this. It is not the goal of this framework to publish things. For such purpose you would use a build script or tool like
Maven - https://github.com/moacyrricardo/maven-slack
Gradle - https://github.com/Mindera/gradle-slack-plugin
Or even more convenient a CI tool like
Jenkins - https://github.com/jenkinsci/slack-plugin
TeamCity - https://plugins.jetbrains.com/search/teamcity?correctionAllowed=true&search=slack
Travis CI - https://docs.travis-ci.com/user/notifications/#Configuring-slack-notifications

Related

2 variants for JUnit execution: TestRunner & JUnitCore

There seem to be two approaches for invoking JUnit tests from the OS command shell:
java junit.textui.TestRunner <class-name>
and
java org.junit.runner.JUnitCore <class-name>
When do we use one versus the other?
Also, are there other ways to invoke Junit tests from the OS command shell?
JUnitCore is an entry point of JUnit - so if you want to run a test programmatically or of from some non-java script, I think, its the way to go for JUnit 4.
TestRunner is something a very old junit 3.x
Notice, that nowadays JUnit 5 is the latest available major release and it has yet another way to run the tests.
The question about different ways of running the tests from command line has been already answered Here so I can't add much to this.
However, I can comment on:
Also, are there other ways to invoke Junit tests from the OS command shell?
Nowadays in regular projects people do not run tests like this, instead they use one of build tools (Maven, Gradle for example) that among other things take care of tests.
So for example if you use maven, you can run mvn test and it will compile everything you need, including source code of tests, will take care about all test dependencies and will run all the tests with the help of build-in surefire plugin.
If you don't want to compile anything (assuming that all the code has been already compiled and all is set, you can use mvn surefire:test)
These build tools are also integrated with CI tools (like Jenkins, etc.) So this is considered to be a solved problem.
So unless you're doing something really different (like writing the IDE UI that should run test selected by user on demand or something) there is no really need to run tests with the options you've mentioned.

How to publish xUnit and jUnit test results to gitlab

I have a jenkins pipeline with test stage that triggered via hook on gitlab. Is there any way to publish test results under gitlab for the triggered build?
Thank you
When looking at a problem like this I typically:
Check the : Jenkins Pipeline Steps Reference - there are gitlab related steps but I don't see anything about JUnit results
Check the Vendor's documentation GitLab's page on JUnit results - it looks like you have to use their runner to get JUnit results - you could investigate whether or not you can run this from your pipeline
Look to see if there is a REST api you can use. The Http Request Plugin is really easy to use to talk to various external servers - if GitLab has an API that you can call you may be able to implement it this way.

Jenkins, xcodebuild -> JUnit-Tests with Appium?

i am using Jenkins CI to build my iOS-Project. For this task, I use a sh-script to build the binaries directly from a git-repo by running xcodebuild and thats working pretty well.
Currently I run JUnit-tests with appium from eclipse to test my app, but I would like to integrate them into Jenkins as well. I found some tutorials to integrate JUnit-tests into jenkins by using ant-scripts, but I dont use ant to build my project.
how can I integrate my JUnit-tests into jenkins, without a ant-script? Or should I use a ant-script?
thank you.
I switched now to Gradle Build Automation which is much easier to handle and can be integrated into Jenkins as well by using Jenkins Gradle Plugin. xCode-Projects can automatically be build from Gradle by using Gradle xcode plugin and its easy to integrate JUnit or NGTests into a Gradle Scripts. In java test classes I am able to use selenium driver against appium server who's remote controlling iOS-Simulator.

JRuby build tool

I'm looking for some build automation tool for JRuby project. Result of this project should be some library that can do stuff. I need to use some Java libraries but I want to work with Ruby. So that's why JRuby.
In this stage, I'm looking for build automation tool that can handle dependencies and download them from remote repository.
I could use Maven for this, but I'm interested in other alternatives that could be more fun to work with.
So yeah, if you are looking for something sexier than Mave, SBT is good option.
Other options are:
Gradle - http://www.gradle.org/ - if you want Groovy rather than scala orientation.
Or Gant - http://gant.codehaus.org/ - for some more in the lines of Ant.
Buildr - http://buildr.apache.org/ - Is another interesting project
I also came across this dead project - http://raven.rubyforge.org/ - But I wonder if something new came to tackle the same item, i.e. using Rake , the ruby build tool, to build java as well.
From a dependency management perspective only, jbundler is a bridge between Maven and bundler that can help you manage your dependencies, whether they are gems or maven artefacts.

Junit reports for Hudson

I am able to successfully run my JUnit test suite from the command line and now I want run these tests from Hudson.
However , for Hudson to generate the reports , it needs a results file (I think in xml format) .
How do I generate a results file from JUnit ?
I am using the following command to run the tests :
java com.nvidia.tests.TestSuite1
Thanks in advance .
Parag.
If you're using ant, you can look at the JUnit task for ant. This is probably the easiest way. You can just add the task at the appropriate place in the script.
If you're using maven, look at the surefire plugin for maven which will automatically run the tests and create the reports in jenkins.
EDIT: If you're not using any build tool (which you should be), then just add the ant build script to jenkins, and you should get the reports automatically.