aspose file tools*
The moose likes Testing and the fly likes tips for procedural cobol  programmer to do java testing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Testing
Bookmark "tips for procedural cobol  programmer to do java testing" Watch "tips for procedural cobol  programmer to do java testing" New topic
Author

tips for procedural cobol programmer to do java testing

Jesus Angeles
Ranch Hand

Joined: Feb 26, 2005
Posts: 2057
Any tips for a cobol programmer who is new on jsp/servlet testing?

I have completed my jsp/servlet/mq/log4j system, but is not knowledgeable yet on how to proceed to do unit testing on the mentioned web application.

(I also am doing the backend mainframe.)

Having done mainframe for a decade, I am more familiar with the way procedural stuff are tested.
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30537
    
150

Jesus,
First let's make sure we are using the same defintion of unit testing - testing without external dependencies like a server.

For each of the aspects you mentioned:
servlets - Use JUnit and a mock object framework to create a dummy HttpServletRequest. Common frameworks are jMock and easyMock.
jsps - The JSPs should just contain presentation. If they contain logic/code, move it to a Java Class and test that
java classes - Just write a JUnit test for the object using mock objects as needed.
mq - You can unit test that the calls are being made. You will probably want to integration test this part too. That way you have tests that show it works with a queue.
log4j - There's nothing really to unit test here. You can assume log4j works and has been tested. If you really want to, you could test that things are being logged (that the calls to log4j are made.)


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Jesus Angeles
Ranch Hand

Joined: Feb 26, 2005
Posts: 2057
Thank you Jeanne. I will keep those in mind and study them.

For now, I might resort to manual testing, or hopefully find a code coverage tool.

My environment now is WSAD(can test in local server or in remote server). Any tips on any code coverage software that I can use in this kind of development setup? e.g. easily integrates with wsad, but not necessarily.

In mainframe, I like code coverage as it identifies paths that I have tested through.
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30537
    
150

Jesus,
All of the free code coverage tools I know of run on top of JUnit. My favorite is Emma.

There are commercial tools like JTest that will tell you the code coverage of code you run through the web. They will also generate unit tests based on the actual behavior. These are of small value for initial testing but have the potential to be helpful for regression testing.

If you are looking at integration testing, consider using an end to end tool like Selenium. This tests completely through the GUI without writing any code. It is more similar to QA regression tests, but I find it valuable.
Jesus Angeles
Ranch Hand

Joined: Feb 26, 2005
Posts: 2057
Last night, I saw this AppPerfectTestStudio80_win and about to try it out now.

But for web application, it says to compile everything first, then feed those classes to the code coverage tool, then do the tests.

But wondering how can I test jsp, when it is dynamically compiled by the container.
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30537
    
150

Jesus,
What are you trying to test in the JSP? Code coverage doesn't really make sense as a raw statistic here. Code coverage of what?

If there is code in your JSPs, extract it to a class and test that. If not, there is no code to take a percentage of.
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Jesus, you can also use JspTest for rendering your JSP's outside a web container and for performing assertions against the resulting HTML.


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: tips for procedural cobol programmer to do java testing