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".
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 4 months ago.
Improve this question
I’ve been having issues lately because my dependencies has been updated to use netty 4.1 and Gatling has not been updated for a while, and still work only on Netty 4.0.
Anybody knows any alternative to Gatling to create similar Simulations and scenarios for the performance test to be run automatically in my Maven life cycle?
If you look for something code-based it would be:
Locust
Grinder
For UI and/or XML based scenario definition you can check out:
Tsung (this one can be reliably run on Linux/Unix only)
Apache JMeter
Check out Open Source Load Testing Tools: Which One Should You Use? to learn more about the aforementioned tools and decide which one fits to your most.
As a nice replacement for Gatling I would recommend you to check the Locust. The good thing about the Locust specifically for you is that it is code based performance testing tool which does not enforce you to write the tests only in a specific programming language like Python. Because if you used Scala before, you might be more comfortable to switch to something like Java or even Kotlin while writing your tests which is more than doable using Locust framework. You can find the handy tutorial by this link:
https://www.blazemeter.com/blog/locust-performance-testing-using-java-and-kotlin
Here's also a benchmark comparison of different tools.
If you are javascript/Ecma familiar k6 does the job.
Apache JMeter is a known alternative to Gatling.
It is frequently updated (at least 2 major releases per year) and has a strong user base and a lot of commercial offers.
There is a Maven Plugin that is being recently much more frequently updated, there has been 4 releases in 2 months.
Look at code coverage in more details.
k6 is a good alternative, if js is not a problem for you. https://k6.io/
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 5 years ago.
Improve this question
I have made a couple dozens of tests for a legacy system I was handed over.
They generally test/describe some high level feature of the system, and I generally include in the test file itself a little comment about that feature. In this way, I both have a regression test suite and I'm compiling knowledge of the system in a single place, so others in the future don't have to lose all the time I lost trying to understand the (up to now) undocumented system.
Now, I was looking for some tool that would allow me to organize and see the high level features in a simpler way than having to look up to the test files. If it allowed a tag system, even better.
I have heard of Fitnesse but it doesn't look to fit really in what I'm looking for. I'm not looking for a tool to bridge the communication between the client and developers.
This project is coded in Java.
Thanks
If you moved the documentation from the unit tests to the classes you are testing, you could use either standard JavaDoc or doxygen.
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 7 years ago.
Improve this question
I'm looking for recommendations for a simple open source implementation of a Distributed Hash Table in Java to play around with. No fancy features, just for learning purposes, no production functionality needed. It should be simple to set up (e.g. 1 physical machine with n-JVMs) and well documented preferably with some examples, tutorials or starting guides.
Research yields these candidates: FreePastry and OpenChord but I'm not fully convinced they meet my criteria simplicity-wise.
Have you got any experience with these or other implementations? Recommendations?
Thanks & adios
There is TomP2P on Github.
Maybe JDHT will fit the bill. I haven't checked it out myself, but it's written at a university, sometimes that means it's simple and used for teaching. :-)
I have been working on an implementation of Kademlia lately. It's very simple to setup and use and it's well documented. There are several tests written that demonstrate the different functionality as well as a starting guide in the Readme.md file itself.
You can use openkad
I started with free pastry..I've had a great experience with it. It was very simple to set up and run a ring of nodes. I've been mainly using PAST (File storage) and its been quite easy to get running. I'd suggest having a look at the PAST tutorial here. https://trac.freepastry.org/wiki/tut_past
The code is over simplified in my opinion but you say that is all you need so I guess thats ok.
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.