JUnit
Simple test.
Create a Main.java file with the following content:
package ru.andreyolegovich.it.junit;
public class Main {
public static void main(String[] args) {
}
static int addFunc(int var_1, int var_2){
int sum = var_1 + var_2;
return sum;
}
}
Now you need to create a file with the test and connect JUnit
IntelliJ just right-click on main → Go To → Test → Create New Test → Select JUnit 5
→ Fix.
You need a code like this.
package com.pluralsight.organized;
import org.junit.jupiter.api.Test;
import static com.pluralsight.organized.Main.addFunc;
import static org.junit.jupiter.api.Assertions.*;
class MainTest {
@Test
public void addCorrectly() {
assertEquals(4,addFunc(1,3));
}
}