CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: JUnit

  1. #1
    Join Date
    Dec 2018
    Posts
    2

    JUnit

    Hi,
    How would i go about writing JUnit test cases for a simple java application? I found this java apllication here @ https://www.includehelp.com/java-pro...ing-class.aspx

    I have been searching all day for examples to cover the basics but I am still at a loss.
    Last edited by 2kaud; December 10th, 2018 at 04:53 AM.

  2. #2
    Join Date
    Dec 2018
    Posts
    8

    Re: JUnit

    Create the unit test class in the same package.

    For example,

    If com.example.MyPrivateClass located in src/main/java/com/example/MyPrivateClass.java

    Then the test class will be in same package
    com.example.MyPrivateClassTestCase and will be located in src/test/java/com/example/MyPrivateClassTestCase.java

  3. #3
    Join Date
    Dec 2018
    Posts
    2

    Re: JUnit

    Thanks kadammanali987
    Can you give a specific example.

    How would i test the addDistance in the example in the link?

    Any help would be appreciated.

  4. #4
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: JUnit

    Quote Originally Posted by newbie12 View Post
    Thanks kadammanali987
    Can you give a specific example.

    How would i test the addDistance in the example in the link?

    Any help would be appreciated.
    I don't mean to be harsh, but learn to use google. For example, try searching for "junit tutorial". Any of the 1000's of hits is going to show you a basic test for a method.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured