fork download
  1. import static org.junit.Assert.assertEquals;
  2.  
  3. public class Main {
  4.  
  5. public static void main(String[] args) {
  6. // Run the JUnit tests programmatically
  7. runTests();
  8. }
  9.  
  10. public static void runTests() {
  11. // Run testStringEquality
  12. boolean stringEqualityResult = testStringEquality();
  13. System.out.println("String Equality Test Result: " + (stringEqualityResult ? "Passed" : "Failed"));
  14.  
  15. // Run testStringInequality
  16. boolean stringInequalityResult = testStringInequality();
  17. System.out.println("String Inequality Test Result: " + (stringInequalityResult ? "Passed" : "Failed"));
  18. }
  19.  
  20. public static boolean testStringEquality() {
  21. String expected = "Hello, World!";
  22. String actual = "Hello, World!";
  23. try {
  24. assertEquals("abc",expected, actual);
  25. return true; // Test passed
  26. } catch (AssertionError e) {
  27. return false; // Test failed
  28. }
  29. }
  30.  
  31. public static boolean testStringInequality() {
  32. String expected = "Hello, World!";
  33. String actual = "Hello, OpenAI!";
  34. try {
  35. assertEquals(expected, actual);
  36. return true; // Test passed
  37. } catch (AssertionError e) {
  38. return false; // Test failed
  39. }
  40. }
  41. }
  42.  
Success #stdin #stdout 0.13s 57580KB
stdin
Standard input is empty
stdout
String Equality Test Result: Passed
String Inequality Test Result: Failed