1package com.javatpoint;2import org.junit.Test;3import org.junit.experimental.results.ResultMatchers;4import org.junit.runner.JUnitCore;5import org.junit.runner.Result;6import org.junit.runner.RunWith;7import org.junit.runners.Suite;8@RunWith(Suite.class)9@Suite.SuiteClasses({TestJunit1.class,TestJunit2.class})10public class TestResult {11 public void test() {12 Result result = JUnitCore.runClasses(TestJunit1.class, TestJunit2.class);13 ResultMatchers.isSuccessful().matches(result);14 }15}16Example 2: How to use ResultMatchers.isFailure() method?17package com.javatpoint;18import org.junit.Test;19import static org.junit.Assert.*;20public class TestJunit1 {21 public void testAdd() {22 int num = 5;23 String temp = null;24 String str = "Junit is working fine";25 assertEquals("Junit is working fine", str);26 assertFalse(num > 6);27 assertNotNull(str);28 }29}30package com.javatpoint;31import org.junit.Test;32import static org.junit.Assert.*;33public class TestJunit2 {34 public void testAdd() {35 int num = 5;36 String temp = null;37 String str = "Junit is working fine";38 assertEquals("Junit is working fine", str);39 assertFalse(num > 6);40 assertNotNull(str);41 assertEquals("Junit is working fine", str);42 }43}44package com.javatpoint;45import org.junit.Test;46import org.junit.experimental.results.ResultMatchers;47import org.junit.runner.JUnitCore;48import org.junit.runner.Result;49import org.junit.runner.RunWith;50import org.junit.runners.Suite;51@RunWith(Suite.class)52@Suite.SuiteClasses({TestJunit1.class,TestJunit2.class})53public class TestResult {54 public void test() {55 Result result = JUnitCore.runClasses(TestJunit1.class, TestJunit2.class);56 ResultMatchers.isFailure().matches