Answers for "writing test cases in junit for spring"

0

how to write a junit test case in java

import static org.junit.jupiter.api.Assertions.assertEquals;

import org.junit.jupiter.api.Test;

public class MyTests {

    @Test
    public void multiplicationOfZeroIntegersShouldReturnZero() {
        MyClass tester = new MyClass(); // MyClass is tested

        // assert statements
        assertEquals(0, tester.multiply(10, 0), "10 x 0 must be 0");
        assertEquals(0, tester.multiply(0, 10), "0 x 10 must be 0");
        assertEquals(0, tester.multiply(0, 0), "0 x 0 must be 0");
    }
}
Posted by: Guest on July-14-2020
1

@test annotation in junit

# Used in JAVA
 public class Example {
    @Test
    public void method() {
       org.junit.Assert.assertTrue( new ArrayList().isEmpty() );
    }
 }
Posted by: Guest on February-04-2021

Code answers related to "writing test cases in junit for spring"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language