Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: how to write test cases for void methods

  1. #1
    Junior Member
    Join Date
    Mar 2014
    Location
    Hyderabad
    Posts
    2
    My Mood
    Cool
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default how to write test cases for void methods

    HI....... I'm trying to write test cases for void methods . So any one can give the solution for how to write.......


    Here is my sample code

    public void objIntoFile() throws Exception
    {
    addAdminObjects();
    file = new File("D:\\ExtractingDB\\export.txt");
    writer = new BufferedWriter(new FileWriter(file));
    writer.write(query);
    writer.write("\nxml on;\n");
    writer.write(buffer.toString());
    writer.flush();
    writer.close();
    }


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,541
    My Mood
    Hungover
    Thanks
    145
    Thanked 648 Times in 553 Posts

    Default Re: how to write test cases for void methods

    Are familiar with the idea of method preconditions and postconditions? Recommended reading: Postcondition - Wikipedia, the free encyclopedia

    What has to be true after this method is called?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    6,103
    My Mood
    Mellow
    Thanks
    244
    Thanked 755 Times in 741 Posts

    Default Re: how to write test cases for void methods

    Welcome to the forum! Please read this topic to learn how to post code correctly and other useful info for new members.

Similar Threads

  1. Void Methods Question
    By Old Valyria in forum Object Oriented Programming
    Replies: 3
    Last Post: December 25th, 2013, 07:46 AM
  2. How can I write a class or something so I can run and test the following code?
    By michael305rodri in forum Java Theory & Questions
    Replies: 3
    Last Post: October 18th, 2012, 11:46 PM
  3. Don't understand void methods, need help!
    By alex067 in forum What's Wrong With My Code?
    Replies: 5
    Last Post: October 9th, 2012, 08:02 AM
  4. Passing variables with void methods
    By knightmetal in forum What's Wrong With My Code?
    Replies: 5
    Last Post: March 21st, 2012, 09:46 PM
  5. How to combine these 3 void methods?..
    By TimoElPrimo in forum File I/O & Other I/O Streams
    Replies: 3
    Last Post: February 8th, 2011, 02:25 PM