Run Junit test in several threads. Can Gatling execute JUnit tests? - java

I need to run existing functional autotests in several threads same time (number of threads will be set in param ) with the aim of load testing.
Functional autotest is written in Java with JUnit and is launching from Jenkins.
Is there any way to implement this task without recording the scenario in the Jmeter?
I heard about the possibility of running tests written in Java in the Gatling framework.
Any ideas?

Yes you can do it using library https://github.com/encircled/jPut. This is exactly what you are describing: using unit tests for perf/load/stress testing with easy integration with CI pipelines thanks to JUnit. Tests itself can be written in any JVM language.

Related

Integration testing running HTTP server instance without mocking?

I have been implementing CI on a legacy project that has very little junit test coverage. I have explained that given where we are that the quickest bang for buck is to deploy and run up the code as part of the weekly build and then hit the running Tomcat instance with a number of HTTP requests. Planning on doing this via JUnit.
Tests will be basic, but cover.
Has server started and can it process HTTP requests.
Are we getting the expected data back from the server.
...
I appreciate that this isn't ideal, but at present there are no tests which enable the dev team to deduce whether the weekly build is good and actually runs.
All of the examples I have found to date seem to mock the actual HTTP request. Is there a framework out there that will provide the functionality to handle http requests and the blocking async results checking?
you can automate a browser with various tools.
A common one is selenium web browser. We couple this with BDD testing/cucumber/specflow for regression and CI.
Others include robot
For tools rather than a framework, you could use badboy, jmeter or grinder
Jmeter could be used with some validations, though it's really a performance testing tool. Why not curl or wget?
Decided that using SpringJunit4ClassRunner and autowiring the required dependencies in each of the test cases makes it simple to create isolated integration tests.

What is the equivalent of Nunit in Java for Eclipse?

I used to test an application using VS & NUnit and NUnit provided this interface which had all my tests listed under each browser. I had a selenium grid setup to run different browsers.
Nunit allowed me to run single test in individual browser or all test in one browser. It was really very useful. Now I am testing an app using Java and Selenium. I am wondering if there is a plugin like Nunit for eclipse so I can run all my tests using specific browser one by one. Any advice is greatly appreciated :) . Thanks
I used to use JUnit and Selenium WebDriver to acceptance test websites
We scratched the idea though, because i (and my other co-workers) had a tendency to overcomplicate the 'point-and-click' automatic acceptance tests, to the point where they were not reliable anymore (we had some huge flow-tests that caused these issues). Now we currently only smoketest HTML pages now, using HtmlUnit (more or less)
The equivalent of NUnit is TestNG or JUnit in Java. You can install TestNG in Eclipse by following the URL:
How to install TestNG in eclipse Kepler

Unit testing framework for my own android library

I'm building an android library for Android developers.
I want start unit testing my library and I'm looking for a good framework.
I saw many articles about Robolectric, but the problem is my library doesn't contain a lot of UI/Activities/Services or other Android elements.
I want to use Robolectric for regular java unit testing, and in not many cases where I need Robolectric for UI/Services test I'll use the Robolectic features.
My questions are:
1. Can I use Robolectric for pure java unit testing? And if I can, I will be happy to get a good tutorial for this.
2. Does Robolectric is the best framework for my needs?
The short answer is yes.
You can setup your project with robolectric & Junit4. Then, when you have tests that do not touch any Android-specific bits, you can just run them as normal JUnit tests. When you need Robolectric, you use the Robolectric test runner. The runner you use is what makes the difference.
You run them all as JUnit tests anyway, so your entire library tests out with one run.

JMeter predefined JMX execution from java code

After searching for a long time I was not able to find a proper solution or documentation on how to run predefined JDBC JMeter Test Suites from java code. The tests have been defined in the JMX format.
I know that you can run it with the jmeter-n.cmd, but I need to execute the test from within my code.
Also, the Runtime.exec solution (as described in the link) is not feasable, as I cannot go out of my JVM.
How to create and run Apache JMeter Test Scripts from a Java program?
Using the JMeter API or GUI, I was able to create some http and JDBC tests - but not run predefined ones.
Creating JDBC tests in the API did not work at all.
There is some basic documentation around, but I can only find solutions on how its done in the GUI.
Thanks and best regards
Refer to 5 Ways To Launch a JMeter Test without Using the JMeter GUI guide, it provides walkthrough on how to launch existing .jmx file from Java code and additionally clarifies how to build a JMeter test plan via API.

What is the standard for testing in Java?

What apps would you use? Are there auto testing suites like autotest for ruby? What do you use and why? To be honest, I don't even know how to write tests, when, or why. I'd like to learn though, I know that it will make me a better developer.
Our team uses Netbeans, not eclipse, although I'm going to still google eclipse responses to see if they are implemented as a Netbeans solution as well.
There are 2 most popular frameworks for unit tests: JUnit and TestNG. Both are annotation based. To create test you have to create class and mark each method that performs test using annotation #Test.
JUnit is older and have more extensions (DBUnit, Cactus etc). TestNG has much more annotations. Very important feature of TestNG is ability to create test groups using annotations.
Yet another group of tools you will probably need is mocking tools (EasyMock, EasyMock etc.)
There are a bunch of testing frameworks that are popular. JUnit is pretty good and comes by default with Eclipse. It provides an API for defining tests and doing assertions, as well as a Testrunner to execute the tests. EasyMock and Mockito work well with JUnit to provide mocking functionality so you can test components in isolation.
For continuous integration, there is Jenkins, which is free.
There are others as well.
I would use junit and possibly a mocking library like jmock.
Most of the automatic "tests" which can be done use the compiler or a code analysis tool like FindBugs.
In addition to what has already been said (JUnit, EasyMock, ...) you may also have a look at Fitnesse: it may be a good tool for full integration and acceptance tests!
Don't forget TestNG. It's the "next generation" beyond JUnit. It handles threaded tests better.
SOAP UI is the right tool for testing SOAP web services.
JMeter or Grinder for load testing.
As JUnit and Mockito was already mentioned, You can look into Infinitest or JUnit Max for autotesting.
http://infinitest.github.com/
http://junitmax.com/
If you are looking for something that implements continuous testing I can recommend two free products:
For a developer during work in Eclipse/IntelliJ IDE:
http://infinitest.github.com/
Infinitest is an Eclipse/IntelliJ plugin that runs your test continuously in the background while you are developing your code.
For a team:
http://hudson-ci.org/
or
http://jenkins-ci.org/
are great continuous integration servers that can do builds and run tests continuously.
Been writing junits for over 7 years now and I highly recommend spock for all your testing needs: unit and integration testing, mocking, end-to-end testing, data driven testing etc

Categories

Resources