java assertions

Solutions on MaxInterview for java assertions by the best coders in the world

showing results for - "java assertions"
Harriet
26 Jul 2016
1import org.junit.jupiter.api.Assertions;
2import org.junit.jupiter.api.Test;
3
4public class AssertionExample {
5
6    /**
7     * The assertionExample function
8     * uses multiple assertions for the purpose of example;
9     * Usually in one method it is recommended to have 1 assertion;
10     */
11    @Test
12    public void assertionExample()
13    {
14        Assertions.assertEquals(2+2,4);
15
16        Assertions.assertNotEquals(6+3,10);
17
18        Assertions.assertTrue("Radu".length()==4);
19
20        String tester = null;
21
22        Assertions.assertThrows(NullPointerException.class,()->tester.equals("emptyString"));
23    }
24}