Aditya Bhogte
Aditya Bhogte

Reputation: 15

Eclipse: Junit I am seeing this error in junit tab below

Below is my simple code

package M06;

    public class ExerciseE03 {

        public double calcTotal (double total, boolean existingMember, boolean validDiscount, boolean validCoupon) {

            double discount=0.0;

            if (existingMember && validDiscount || validCoupon) {
                if (total > 1_000.0)
                    discount = 0.15;
                else
                    if (total >= 750)
                        discount = 0.1;
                    else
                        if (total > 500)
                            discount = 0.05;
                        else
                            discount = 0.025;
            }
            return (total * (1-discount) * 1.0825);
        }
    }

and this is the j unit file

package M06;

import static org.junit.Assert.*;
import static junitparams.JUnitParamsRunner.$;
import org.junit.Before;
import org.junit.Test;

import junitparams.FileParameters;

public class ExerciseE03Test {
    private ExerciseE03 object;

    @Before
    public void setUp() throws Exception {
        object = new ExerciseE03();
    }

    @Test
    @FileParameters("src/M06/E03TestCaseTable.csv")
    public void test(int testcaseNumber, boolean member, boolean disc, boolean coupon, double total, double discount, double output) {
        //ExerciseE03 object = new ExerciseE03();
        //assertEquals(1380.1875, object.calcTotal(1500, true, true, true),0.001);
        object.calcTotal( total, member, disc, coupon);
        assertEquals(output,object.calcTotal(total, member, disc, coupon),0.01);
    }

}

I am also providing my junit screenshot below. since i am new to juint, i don't know what are steps to be taken for this type of error

enter image description here

Above is the error that i can see in my junit tab below.

Upvotes: 0

Views: 99

Answers (1)

Use the @RunWith(JUnitParamsRunner.class) annotation on the top of your test class, ExerciseE03Test.

@RunWith(JUnitParamsRunner.class)
public class ExerciseE03Test {

Check this post to learn more.

Upvotes: 1

Related Questions