Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this question
I have a Java project created in IntelliJ and using Gradle.
My repository is hosted on GitHub, I've also integrated Travis CI.
My tests are done using JUnit and Mockito, Java 8.
I'm looking for a tool that would automatically run tests whenever I push to my repository, providing me with information if tests passed and code coverage information. Would like it to generate a GitHub badge just like Travis CI does, so that I can see how each branch is covered and if it's passing.
Thanks!
I decided to go with Codecov
Here's my GitHub repo with example implementation.
I use JaCoCo to capture coverage statistics which get published to Coveralls to track coverage changes between builds and visualize the results. Coveralls also provides a badge with a coverage percentage.
Gradle/Travis/Github examples here and here
With https://codecov.io/, the official example here is more up to date compared to the best answer:
https://github.com/codecov/example-gradle
However, I the CodeCov badge is set up in a nice way in the best answer's code, compared to the official examples which seem to have no badge in the README.
EDIT: After trying to set up all of this, I really disrecommend using CodeCov for private repos (although it can work well for public repos). Full of bugs. Very mad.
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
We are currently working on releasing an Android application to the Google Play Store before which we are planning to do performance test for our application to detect unused and redundant code.
Like for instance, consider the following code snippet as an example
double x = sqrt(2);
if (x > 5)
{
doStuff();
}
Is there any testing tool in the market that goes through the source code and helps identify such blocks of code?
You can do static code analysis of your code using libraries like Findbugs, PMD and alternatively you can use Sonar runner to run these analysis on SonarSource Server and have your results published to a SonarSource dashboard when building your code. Also it would good to have these things run nigthly on a Continuous Integration Server like Jenkins or TeamCity.
Check this presentation on how to integrate with your gradle build. Also you can refer to gradle SonarSource plugin documentation on how to configure in your gradle build script.
Sonar analysis usually take quite a while to run since you can configure to run quite a few other things apart from static code analysis, like code coverage, CheckStyle rules, etc. which may increase your build time. Hence, you should probably configure to run these analysis every nightly and for every build perhaps you can run just FindBugs and Checkstyle to run static code analysis which should be a lot faster.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this question
I would like to know about good tools to automatically generate JUnit4 tests. By automatic generation, I mean that if I write a .java file, then a test file for the same should be created with method placeholders and setup/teardown in place (like the auto-generate constructors feature of eclipse)
I found some but I haven't tried them all and frankly I am overwhelmed by the plethora of choices. I was wondering if someone has tried some/all of them and has any recommendations from these or any other.
http://moreunit.sourceforge.net/
http://sourceforge.net/projects/junitgenerator/
http://sourceforge.net/projects/junittestmaker/
http://jub.sourceforge.net/
http://testcasegen.sourceforge.net/
http://www.softpedia.com/get/Programming/Other-Programming-Files/JUnit-Test-Generator.shtml
http://mediakey.dk/~cc/generate-junit-tests/
http://developers.google.com/java-dev-tools/codepro/doc/features/junit/test_case_generation?hl=hu-HU
http://agile.csc.ncsu.edu/SEMaterials/tutorials/fit/
I use the Eclipse plugin MoreUnit. It can generate TestClasses and test-methods. It also shows which methods have test methods ...
Together with TestNG(JUnit is also good) and EclEmma junit testing is quite easy to handle and keep track on the code coverage
Some suggestions: Randoop, AgitarOne, and EvoSuit for Java.
The Squaretest plugin for IntelliJ IDEA works well. It can auto-generate test-classes with a lot of the required boilerplate code. It supports creating tests in either Java or Groovy with the JUnit4, JUnit5, AndroidJUnit4 or Robolectric3 test frameworks.
Disclaimer: I created the Squaretest plugin.
CodePro Analytix Plugin for Eclipse is also good. Exiting thing for me is it generates multipe testcases covering all the execution paths of a method, analyses dead code and dependencies and has lot of other features.
Check out the User Guide here
My favorite is JUnit-Tools to generate JUnit Tests and more. It's a eclipse plug-in and up to date. Further there are many possibilities to configure and to adapt.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
I need good examples of Junit tests for Java classes, to spend in training, anyone have suggestions of good examples?
Here is a good one which shows you step by step what you have to do, including screenshots with Eclipse also.
From memory, I think Kent Beck's Test Driven Development walks through some good examples. Probably a good book to refer to in testing training courses. http://www.amazon.co.uk/Test-Driven-Development-Addison-Wesley-Signature/dp/0321146530
You can have a look at open source software - maybe a library which you use for yourself. They often contain unit tests, e.g.:
Apache Commons lang test code
Google guava libraries test code
and for sure a lot more....
I do not know what you mean with 'to spend in training' but if you will use it for other purpose than to train yourself check the license first.
JUnit tests are somehow based on your procedures. It depends what do you want to test. For example, if you want to test if for specific input, you receive specific output, you can use assertEquals. For writing a simple step by step JUnit test in Java in Eclipse, look at "Write Simple JUnit Test".
For thorough information, look at "Unit Test Tutorials".
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 8 years ago.
Improve this question
Our project will integrate mutation testing as part of its build cycle. Right now, we are on the evaluation phase.
So far, I have only found that Jester has a maven-plugin (Grester). I have not been able to find anything for the other mutation testing tools available (Jumble, µJava and Javalanche). Of course, we want full maven integration. We do not want to reinvent the wheel (i.e., write our own maven plugin for the tool that we choose).
Do you know of any maven-plugins for those Jumble, µJava and Javalanche? I've already googled and, like I said, have only found Grester. Also, if you know of any other mutation testing tools for java, any hints will be greatly appreciated.
PIT, provides a Maven plugin.
It's available from Maven central and has the advantage of being considerably faster than Jester, Jumble or muJava. It is also actively developed and supported which does not seem to be the case for Jester or muJava.
(disclosure I'm the author and am probably unfairly biased)
Of the mutation testing tools in the java world, I've found this about Maven support:
µJava: no
Bacterio: no (uses its own ide)
Javalanche: no (uses its own ide)
muTest (µTest): no
Jumble: yes
PIT: yes
Jester: yes
Simple Jester: no
Judy: no
MAJOR: no (uses its own compiler)
(This information was found by googling and from the article Delahaye, du Bousquet: A Comparison of Mutation Analysis Tools for Java.)
My vote would also go for PIT.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
I'm having a hard time making the connection between testing and code. I could ask numerous questions here about things like directory structure and naming of test classes and JUnit 3 vs 4 and so on, but I'd rather find a sample project that does it right and learn by reading it.
I'd like something not too complex so that I can understand it easily, and JUnit 4 would be best (no reason to stick with 3 since I'm starting fresh, right?). I'm on Windows 7, I use Eclipse and I'm planning/hoping to learn and use Hudson. I like Ant, haven't had a good experience with Maven but that's cool too.
Is there a sample project out there that fits this criteria?
edit: Neither of these answers mentioned Hudson; I really like the Craftsman articles (and maybe it goes into continuous integration) but does anyone else have any other suggestions?
I found the Craftsman articles by Robert Martin (Uncle Bob) an excellent resource for learning effective unit testing. It focuses on Test Driven Development and walks you through the experience of a new coder learning how to test code. The first article can be found here and is called The Craftsman #1: Opening Disaster.
If you're looking for an easy example of project structure and convention, I would recommend giving Maven another go. To use it with Eclipse, install the M2Eclipse plugin, and create a Maven project using one of the Maven archetypes. The archetypes build simple template projects, including source and test structure, and will run with Maven and Eclipse right away.