Results 1 to 2 of 2
  1. #1
    Crawler is offline Member
    Join Date
    Jan 2014
    Posts
    1
    Rep Power
    0

    Default Having trouble with Netbeans 7.2.1 JUnit test

    Hi,

    I am new to Java and Netbeans and am having trouble with a Netbeans 7.2.1 JUniit test of a simple program using an enum. The program, enum class, and Junit test compile.
    When I run the Junit test I get the following error:

    I've changed the enum to an int and verified that the test runs correctly. Very much appreciate suggestions!
    Thanks!



    ***Error message***

    Testsuite: bradym02.BookTest
    Tests run: 0, Failures: 0, Errors: 1, Time elapsed: 0.107 sec

    Testcase: bradym02.BookTest: Caused an ERROR
    Constructor must call super() or this() before return in method bradym02.Binding.<init>()V at offset 0
    java.lang.VerifyError: Constructor must call super() or this() before return in method bradym02.Binding.<init>()V at offset 0
    at bradym02.BookTest.setUpClass(BookTest.java:28)


    *** Enum definition***
    File binding.java:

    package bradym02;

    public enum Binding {
    HARDCOVER, PAPERBACK, EPUB, MOBI, APK
    }


    *** JUnit Test***
    File BookTest.java:

    public class BookTest {

    static BradyM02 courseText; // static required by compiler

    @BeforeClass

    public static void setUpClass() { // static required to run
    courseText = new BradyM02("Horstmann/Cornell",
    "Core Java2, Volume I - Fundamentals", "Manning", Binding.PAPERBACK, 762);
    }

    Line 28 from the error message is: courseText = new BradyM02("Horstmann/Cornell",



    ***File BradyM02:***

    class BradyM02 {

    // The fields.
    String author;
    String title;
    String publisher;

    Binding binding;

    int pages;

    String refNumber;

    /**
    * Constructor. Set the author, title and binding fields when this object
    * is constructed.
    */
    BradyM02(String bookAuthor, String bookTitle, String bookPublisher, Binding bindingType, int numPages) {
    author = bookAuthor;
    title = bookTitle;
    publisher = bookPublisher;
    this.binding = bindingType;
    pages = numPages;
    refNumber = "";
    }

  2. #2
    wsaryada is offline Senior Member
    Join Date
    Jun 2007
    Location
    Bali, Indonesia
    Posts
    758
    Rep Power
    8

    Default Re: Having trouble with Netbeans 7.2.1 JUnit test

    I didn't find the error you've said above. You might considered to re-post your complete code line by line so we can have a better look.

Similar Threads

  1. Junit Test for Poker
    By NoobieCode in forum New To Java
    Replies: 1
    Last Post: 04-12-2013, 01:28 PM
  2. Replies: 1
    Last Post: 08-03-2009, 05:31 PM
  3. JUnit Test Help!
    By pharo in forum New To Java
    Replies: 0
    Last Post: 04-10-2009, 05:15 PM
  4. Junit test
    By alice in forum New To Java
    Replies: 1
    Last Post: 06-14-2008, 01:24 AM

Posting Permissions

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