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)); } }

Search this site

Channel @aofeed Chat @aofeedchat

Contacts and cooperation:
I recommend our hosting beget.com
Write to info@aredel.com if you:
1. Want to write an article for our site or translate an article into your native language.
2. Want to place thematically relevant ads on the site.
3. Ads on my site pass maximum censorship. If you see an ad block unsuitable for school-age children, shocking or misleading - please contact us by e-mail
4. Found a mistake, inaccuracy, bug, etc. on the site. ... .......
5. Articles can be shared on social media by clicking a network icon: