I am a student and I have developed a web application based on JSP. Now my professor has suggested that i should do some tests like unit test etc for my web application.
Can anybody suggest what other test can I use to demonstrate the performance of my application.
And also any good resource from where I can study how to do unit testing, as I have never done any testing before.
Thanks!
Selenium is a popular framework for client-side unit tests (i.e. automating client input on a web page). The site also has a lot of introductory material.
For testing the server-side stuff the good, old JUnit will suffice - it's integrated in all major IDEs.
You should look into Kent Beck's Test-driven Development, although Test-Driven development is more than regular unit testing, this book will enlighten you (I bet) and you will write way better unit tests, too.
Selenium http://seleniumhq.org/
You should do unit testing for individual backing beans, an behavioural testing with something like Fitnesse
What you're talking about is "integration testing."
"Unit testing" is for proving the correct operation of individual components.
You can use SOAP UI to test SOAP-based web services.
You can automate testing of HTML user interfaces using Selenium UI.
Use JUnit for unit testing Java components, NUnit for .NET, etc.
Related
I am exploring multiple options to create a framework for automation testing of Restful Services. This should have suitable reporting for product to view, so our company standard is to use BDD hence for now, I have kept the Karate aside. Only looking for pure Gherkin BDD in JAVA only. (sorry no python, postman tools etc too)
can you guys share me on what cases do you use spring Test or spring boot framework and on what cases do you prefer to use serenity/cucumber/ rest assured.
I understand that these are
just frameworks and both do the jobs alike. I am not looking to make the API automation work, instead looking into the weights for which they are opted for.
My Dev team uses SpringBoot, and we maintain separate repositories. No way do they help in automating our scenarios.
I know SO is not the platform to have comparisons, here I am only seeking the use cases to adopt the framework but not comparison among tools
We are starting on a web application and thinking of TDD development. Can anyone please provide me a list of open source tools to automate our testing.
Thanks in advance
Kaushik
First and the most important: Jenkins Continuous Integration Server (or a CI server from some other vendor).
You can also take a look at a list of CI servers in comparison.
There are also many other tools that ease the process of development using TDD such as:
Obviously Unit test frameworks (JUnit, TestNG)
Mocking frameworks (EasyMock, Mockito, PowerMock)
Also, don't forget Maven for building, Selenium for automating web app testing and JMeter for load testing.
Cheers,
Take a look at cucumber for BDD, it integrates with Jenkins and might help you with your acceptance tests.
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
I'm very new to JUnit, but I want to set up some tests which does the following..
Tests a range of server to server API calls - verifying the responses are correct - I can do that fine.
Open a web page, enter data onto it and verify what happens on submit - This I am struggling with. Is it even possible?
I am thinking that I could call a web page using a server side http web request, but I'm not sure how I can interact with the site itself, i.e. enter data into the forms.
Any thoughts?
Thanks
Steve
You could use Selenium for this. I suggest you use the version 2 which is currently in development and should have a beta available soon (alphas are already available).
Have a look at Selenium, it's a system to test web applications (and de facto websites) you can write all your tests in java. There is an ather project named Tellurium, based on Selenium but Tellurium works with groovy and a DSL, it might be easier to handle at first.
How does this works ?
First you create tests in java (Selenium) or groovy (Tellurium)
Then you start your tests. It will work with your web browser. The application will interact with your browser to test every inch of your application (as you coded it)
At the end it give you a report about yours tests, just as JUnit do.
You can also exploit the nature of the web. There's no real reason to render a form, fill it out and submit it to test the form processing code. The display of the form is one HTTP request, and the submission is another. It's perfectly reasonable to test form submission code by mocking up what a browser would send and asserting that it's handled correctly.
You do need to make sure that the form rendering and submission test code are in sync, but you don't necessarily need a full integration for this either.
There are tools that allow testing without booting up a browser... one that springs to mind is HTMLUnit (and there are others). If you find that Selenium is a pain to write, or the tests brittle or flakey, look for simpler tools like this.
I suggest you to try the Robot Framework. This is an open source testing framework developed by engineers in Nokia Siemens Networks.
It is primarily built on python and the Selenium testing libraries. It also includes support for testing Java/J2EE server side code through Jython libraries. I personally use it in my work sometimes, and writing a test case is just as easy as describing an end-to-end flow through the use of Keywords (most of required ones are already inbuilt). You could go ahead and give this a shot if you find Selenium a li'l tough to work with. The Robot framework provides a fairly simple abstraction over raw selenium, coupled with the power to make Java/J2EE server-side calls too.
Regards,
Nagendra U M
I want to ask for your prefered way to test Java EE code?
I found only three project, that are trying to help to code unit tests in Java EE environment:
http://jakarta.apache.org/cactus/ : Last Published: 2009-01-18
http://www.junitee.org/ : Last Release: 2004-12-11
http://ejb3unit.sourceforge.net/ : Last Release: 2008-05-17
So I wonder,
is there any framework helping to write (j) unit test for Java EE code?
do you use embedded Java EE servers like jboss or glassfish v3?
do you mockup and inject by yourself?
Thanks a lot...
If by Unit Testing you mean... unit testing (testing a unit in isolation), then you actually don't need any particular framework since EJB3.0 are nothing more than annotated POJOs and thus can be relatively easily tested without any special fixture.
Now, if you mean something else - like Integration Testing or Functional Testing - then, yes, tools can help and simplify things (but you should really start to use the right terminology :) I'll assume that this is what you have in mind.
First, JUnitEE seems dead and obsolete and I'm not even sure it has anything for EJB3.x. Second, I'm not impressed by the Java EE 5 support of Cactus and having to deploy Cactus tests is painful (I think that Cactus was nice for J2EE 1.4 but is a bit outdated now). So this leaves us with Ejb3Unit which is in my opinion the best option, especially if you want to run out of container tests i.e. without really deploying the application (much faster).
If you want to run in container tests, then you could indeed use an embedded container and my current preference goes to GlassFish v3, even for Java EE 5 (I may be wrong but I'm pretty disappointed by the starting time of the latest JBoss releases so it isn't getting much of my attention). See the post GlassFish Embedded Reloaded, an appserver in your pocket for sample code (that you could use from your tests) or Using maven plugin for v3 embedded glassfish (if you are using maven).
Another option would be to package and deploy your application with Cargo and then run some tests against the deployed application (with Selenium or a BDD tool for example). This could be useful if you want to run end-to-end tests with a container that doesn't provide any embedded API.
So, to answer your last question, I would indeed use available tools, maybe a combination of them, for tests that are not unit tests and wouldn't mock/inject stuff myself, except if they don't cover some needs that I can't think of right now.
As you are interested in unit testing, I recommend JUnit. You can unit test the methods in the core classes. If you have difficulty in writing unit test cases using JUnit, then probably the design is not modular and it is highly coupled. First focus on your core functionality and test it using JUnit.
I've been facing the same problem of running integration tests based on JUnit in a Java EE 6 container (Glassfish v3, to be precise), and after a lot of browsing and searching, I could not find a solution that really suited me needs, so I wrote my own, now published as jeeunit on Google Code.
I wouldn't call it a test framework, it is really just a handful of classes providing the glue between JUnit and Embedded Glassfish.
The general idea is similar to Cactus, your tests run in the container and get triggered by a servlet from outside.
jeeunit supports JUnit 4, Glassfish v3, CDI and generates the standard XML JUnit reports just like Ant or Maven Surefire (in fact, I reused some code from Ant for generating the reports).
I had a requirement to test a CDI application and wrote a custom JUnit runner that runs everything outside of the web container.
http://jglue.org/cdi-unit/
It is suitable for Java SE and also supports dummy Request, Session and Conversation scopes for testing web apps.
It's small and fast, which is great when you have lots of unit tests.