spencerlarry spencerlarry - 3 months ago 25
Java Question

JUnit testing method is undefined

I keep getting an error when I try to test a method I created. I have a more complicated method, but I get the same error even with a simple method I created so that's what I showed below.

Method

package example;

import java.awt.Color;
import java.awt.Graphics;
import java.util.ArrayList;
import java.util.Scanner;

public class GraphingMethods
{

public static int multiply (int x, int y)
{
return x * y;
}
}


Test

package example;
import static org.junit.Assert.*;
import java.util.ArrayList;
import java.util.Scanner;
import org.junit.Test;
import example.GraphingMethods;

public class Tests
{
@Test
public void testMultiply()
{
assertEquals(10, multiply(2, 5));
}
}




When I hover the mouse over
multiply(2, 5)
it shows the following message in Eclipse.
What am I missing?


Answer

Are they in the same class? If not, you'll need to address the multiply by 3 part name

{package}.{class}.multiply
Comments