public class SUnit 1)public static int testsRun() Returns the total number of te
ID: 653619 • Letter: P
Question
public class SUnit
1)public static int testsRun() Returns the total number of tests run. 2)public static int testsFailed() Returns the number of tests that have failed 3)public static void assertTrue(boolean actual) Verifies that a value is true. If the value is not true a message and stack trace is printed using the printStackTrace method of java.lang.Throwable. The message must be: "Error: Expected true, found false" 4)public static void assertFalse(boolean actual) Verifies that a value is false. If the value is not false a message and stack trace is printed using the printStackTrace method of java.lang.Throwable. The message must be: "Error: Expected false, found true" 5)public static void assertEquals(long expect, long actual) Verifies that two values are equal. If the values are not equal a message and stack trace is printed using the printStackTrace method of java.lang.Throwable. The message must be: "Error: Expected X, found Y" 6) public static void assertEqualsReference(java.lang.Object expect, java.lang.Object actual) 7)public static void assertNull(java.lang.Object actual) 8)public static void assertNotNull(java.lang.Object actual) Can anyone help me with these functions please??
Explanation / Answer
public class SUnit
{
private static int tests = 0;
private static int success = 0;
private static int fail = 0;
public SUnit()
{
tests = 0;
success = 0;
fail = 0;
}
public static int testsRun()
{
return tests;
}
public static int testsFailed()
{
return fail;
}
public static void assertTrue(boolean actual)
{
assert(actual);
}
public static void assertFalse(boolean actual)
{
assert(!actual);
}
public static void assertEquals(long expect, long actual)
{
assert(expect == actual);
}
public static void assertEqualsReference(java.lang.Object expect, java.lang.Object actual)
{
assert(expect.equals(actual));
}
public static void assertNull(java.lang.Object actual)
{
assert(actual == null);
}
public static void assertNotNull(java.lang.Object actual)
{
assert(actual != null);
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.