lundi 28 septembre 2015

Junit + Netbeans: Doesn't find methods inside class for test

I have made a very simple class to test for proper Junit test generating. The problem is that when I create a Junit test, it doesn't find my methods for some reason. I have tried with multiple very simple classes without success. I am starting to think I set up Junit for the project incorrectly. Here is my simple class I am trying to test:

package controller;

public class SampleProgram {

    public int multiply(int x1, int x2){
        return x1 * x2;
    }
}

Here is what is generated when I create a Junit Test in Netbeans:

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package controller;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;

public class ProgramTest {

    public ProgramTest() {
    }

    @BeforeClass
    public static void setUpClass() {
    }

    @AfterClass
    public static void tearDownClass() {
    }

    @Before
    public void setUp() {
    }

    @After
    public void tearDown() {
    }

}

Any help as to why my method isn't being found and generating the test is much appreciated. I have not used Junit before and am completely lost. Thanks

Aucun commentaire:

Enregistrer un commentaire