Win a copy of Head First Android this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Debugging junit test

 
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Hi,

I am using "jdk 1.6u12" ,"eclipse ganymede 3.4.0" and "junit 4".I want to debug my junit tests.So I have put break point at the first line of "setUp" method as well as at the first line of my test method.When I started debugging the thread is halted at the breakpoint at "setUp" but once "setup" is complete it is not going to the test method.Any help regarding debugging of junit test is anticipated.

Thanks,
Arka
 
Saloon Keeper
Posts: 24555
168
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you can breakpoint setUp OK, then it's most likely that jUnit doesn't thing that your test is really a test and isn't calling it.

In order for jUnit to know that a method is a test and not some sort of subroutine or something, you have to properly mark it. For jUnit4, that would be to precede the test with the "@Test" annotation. Also, I think it has to be public, returning void, but I'd have to RTFM to be sure.
 
Arka Sharma
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

In order for jUnit to know that a method is a test and not some sort of subroutine or something, you have to properly mark it. For jUnit4, that would be to precede the test with the "@Test" annotation. Also, I think it has to be public, returning void, but I'd have to RTFM to be sure.



All the test methods are marked as @Test and they are public also.
 
Tim Holloway
Saloon Keeper
Posts: 24555
168
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Eclipse doesn't treat jUnit any different than any other debugged software. With the exception that when you select "junit debug" from the menu, it will launch the jUnit main class as the application to be debugged.

So the next thing I'd check would be to see if there was a problem with the unit test source code being out of sync with the compiled class. That would put the breakpoints in unexpected places.
 
Arka Sharma
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

This issue has been solved.Actualy internally junit was calling several other methods for which source was not found.So eclipse displayed that message.I keep doing step over after calling those methods internally it entered inside the test method.Again internal methods are called between test method and teardDown.

Thanks Tim for your reply
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic