The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

troys (1) [Avatar] Offline
I'm trying to compile the example from chap 2.

import static org.junit.Assert.*;
import org.junit.Test;
public class ParameterizedTest {
private double expected;
private double valueOne;
private double valueTwo;
public static java.util.Collection dataParameters() {
return java.util.Arrays.asList(new Object[][] {
{2,1,1}, //expected, valueOne, valueTwo
public ParameterizedTest(double expected,
double valueOne, double valueTwo) {
this.expected = expected;
this.valueOne = valueOne;
this.valueTwo = valueTwo;
public void sum() {
Calculator calc = new Calculator();
assertEquals(expected, calc.add(valueOne, valueTwo), 0);

I get the following errors.

$ javac -cp ".;c:junit4.5junit-4.5.jar;c:junit4.5" 2>
&1|less cannot find symbol
symbol: class RunWith
^ cannot find symbol
symbol : class Parameters
location: class ParameterizedTest
2 errors
felipe.leme (18) [Avatar] Offline
Re: Probmems with RunsWith
Hi Troy,

First of all, sorry for nobody had answered your question yet - apparently, we haven't received any forum notifications recently.

Anyways, it looks like the sample code is missing the following imports:

import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
import org.junit.runner.RunWith;

Please add these lines, try again, and let us know if you still have problems.

-- Felipe