How to benchmark the methods inside JUnit test? - java

I need to identify the slow running methods inside JUnit test class. For example Surefire site report can give me the test methods running time, but how to identify the running time of the methods inside?
I have the following contraption:
Programming language - Java
Build tool - Apache Maven
Test runner - Apache Surefire
Test driver- JUnit
Browser driver - Selenium WebDriver
Artifacts repository - Sonatype Nexus
Continious integration - Jenkins
SCM - Subversion (to be migrated to Git)

Related

Build the testing repo before deploying to production in Jenkins

So I have a BDD testing project for a service and what I want is that as soon as I merge a branch into the master branch of that service then that BDD testing should be triggered first and if every test case passes then only it should allow to deploy the service to production.
The BDD is written in Cucumber-Java.
You need to configure this in a CI server such as Jenkins.
You can consider these steps, when setting up Jenkins, to achieve your use case:
Use Git-hooks; This will trigger a Jenkins pipeline as soon you merge a branch into the master. Check this article for more info https://kohsuke.org/2011/12/01/polling-must-die-triggering-jenkins-builds-from-a-git-hook/
Then in Jenkins, run your BDD project. Here is a nice article, which explains how cucumber projects are setup and run in Jenkins:
https://faun.pub/running-cucumber-tests-with-jenkins-a5a3a8df07eb
When your cucumber project passes, then write a script in Jenkins to deploy into production (This would be a separate stage in Jenkins). Although I would recommend you to deploy this into a staging server or something like Artifactory, which would hold your release package and have a manual step to deploy into production.
Finally here is a detailed article that gives step by step explanation of how you could integrate NoCodeBDD with Jenkins. Though this article is for NoCodeBDD, you could copy these steps and apply them for any BDD project by changing some parts of the script.
https://blog.nocodebdd.com/integrate-nocodebdd-and-jenkins-to-run-bdd/

Can I add Jmeter to the project that use Gradle Java and Junit 5?

I have an Automation test project with an API test included.
I use for that JUnit, Retrofit2, Java, and Gradle.
I want to integrate Jmeter to those tests and run performance testing using those tests. It is possible?
Can I (for example) package all of those tests to the jar, and run it using plugin before running the tests?
I saw some topics on the stack overflow and other forums, but it was for Maven and Junit.

TFS and TestNG - Possible to Execute TestNG test(s) within TFS2015?

TFS and TestNG - Possible to Execute TestNG test(s) within TFS2015?
I have uploaded a Java Maven project to a Repo in my instance of TFS.
My java Maven project comprises of TestNG Test / classes
I can see that there is a Maven plugin within the TFS which also has a JUnit link.
4. I cant see any option to enable me to execute TestNG tests within the TFS, is it even possible?
It's able to use Maven task to build a Java application or test the application including TestNG test. Detail steps please refer this tutorial: Get started testing Java applications with Visual Studio Team Services
For test result report just follow juherr's reply in this question.
Yes you should be able to run your TestNG tests.
I think its eventually going to be Maven that is going to be executing your tests.
Maven makes use of surefire-plugin to basically execute your tests. For TestNG here's two of executing tests via surefire-plugin
If your test matches the default pattern "/Test*.java", "/*Test.java", "**/*TestCase.java" (See here)
Create a suite xml file for TestNG (See here) and have surefire plugin refer to it (see here).

Run integration tests in Vagrant with Maven

I am working on augmenting a test framework that uses Maven. Due to the nature of the code being tested, it is necessary to run tests in VMs. We are currently doing this in a sort of hack-ish way by running shell scripts that SSH into the VMs via Vagrant and run a list of tests. However, this list of tests has to be updated every time someone adds a new integration test to our tests. Ideally, we'd like to automatically gather the relevant tests that are flagged as Component / Integration tests with #Category JUnit flags in our Java code, and then run these tests within the VMs. It seems like Failsafe has no parameters to run the integration tests outside of the local machine. Is there any way to do this using existing Maven plugins?
Ideally, the flow of things would be as follows:
Discover all component / integration tests using Failsafe.
Pass the list of these tests into a VM
Run the tests on that VM, preferably with vagrant.
The existing plugin for Vagrant in Maven shows how to run a VM during integration tests, but it doesn't make clear how to actually run the integration tests on the VMs within Maven: http://nicoulaj.github.io/vagrant-maven-plugin/examples/running-a-vm-during-integration-tests.html . The plugin hasn't been updated since 2013 either, which isn't very promising.

How can I view integration tests in the Netbeans Test Results?

My development environment is Netbeans 7.4 and Maven 3.0.5 (bundled with Netbeans). I'm using JUnit 4.11 to build unit (class names ending with Test) and integration tests (class names ending with IT). I'm running unit tests and excluding integration tests with the "-DskipITs" Maven option. I have a custom action which runs just the integration tests with the failsafe plugin. Both execute successfully. However, I only see the results in the "Test Results" window when running the unit tests. How can I get the integration tests to show in the "Test Results" window? With the integration tests, I'm only seeing the output in the console.
The maven-failsafe-plugin only executes in integration-test and verify (and of course the help) goal while the maven-surefire-plugin runs during test goal.
NetBeans Test Results window only shows the tests that were executed using the 'test' goal.
My solution for this situation is to categorize my integration tests into
testintegration - just lightweight ITs, I run them with surefire (to see them in Test Results window)
testheavy - those that will require me to bootstrap something I run with the fail-safe plugin
I hope you have the option of doing something close to that.

Categories

Resources