dcsimg
can't understand super call
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Ian_Brown
Posted On:   Wednesday, October 8, 2003 01:56 AM

Hi, I'm new to Junit and usimg it on JBuilder and was writing simple test case just to see it working; now the following code worked for String but is giving me grief on the line super(testMethodNumber); can anyone see why? here's all the code; import junit.framework.TestCase; class Number { int number1; int number2; int result; public Number(int n1, int n2) { number1 = n1; number2 = n2; } public Number() { number1 = 0; number2 = 0; } public int getNumber() { result = number1 +    More>>

Hi,
I'm new to Junit and usimg it on JBuilder and was writing simple test case just to see it working; now the following code worked for String but is giving me grief on the line super(testMethodNumber); can anyone see why?

here's all the code;


import junit.framework.TestCase;


class Number {


int number1;


int number2;


int result;


public Number(int n1, int n2) {


number1 = n1;


number2 = n2;


}


public Number() {


number1 = 0;


number2 = 0;


}


public int getNumber() {


result = number1 + number2;


return result;


}
}



class TestNumber extends TestCase {


public TestNumber(int testMethodNumber) {


super(testMethodNumber);


}


// A unit test to verify the number is added correctly


public void test_add_Number() {


Number p = new Number(1,1);


assertEquals(2, p.getNumber());


}



}

   <<Less

Re: can't understand super call

Posted By:   Anonymous  
Posted On:   Thursday, October 9, 2003 11:27 AM

TestCase doesn't have a constructor which gets an int as argument.

If you are using the newest version of JUnit, your testcase class doesn't need any constructor at all, by the way.

About | Sitemap | Contact