----------------------------------------------------------------------------------------
public class junitTest {
private String msg;
public junitTest(String msg)
{
this.msg=msg;
}
public String printmsg()
{
System.out.println(msg);
return msg;
}
}
public class junitTest {
private String msg;
public junitTest(String msg)
{
this.msg=msg;
}
public String printmsg()
{
System.out.println(msg);
return msg;
}
}
-----------------------------------------------------------------------------------
import static org.junit.Assert.*;
import org.junit.Test;
public class junitTestTest {
String msg="sree";
junitTest obj = new junitTest(msg);
@Test
public void testing()
{
assertEquals(msg,obj.printmsg());
}
}
=============================================================
public class MyClass {
public int multiply(int x ,int y)
{
if(x>10)
throw new IllegalArgumentException("x should be less than 10");
return x*y;
}
}
import static org.junit.Assert.*;
import org.junit.Test;
public class MyClassTest {
@Test
public void TestMultiply()
{
MyClass test = new MyClass();
System.out.println(test.multiply(2,3));
assertEquals(45,test.multiply(5,9));
}
}
=======================================================
public class MyClass {
public int multiply(int x ,int y)
{
if(x>10)
throw new IllegalArgumentException("x should be less than 10");
return x*y;
}
}
-------------------------------------------------------------------------------
import static org.junit.Assert.*;
import org.junit.Test;
public class MyClassTest {
@Test
public void TestMultiply()
{
MyClass test = new MyClass();
System.out.println(test.multiply(2,3));
assertEquals(45,test.multiply(5,9));
}
}
=======================================================
No comments:
Post a Comment