简体   繁体   中英

Cannot import Assertions from JUnit

I am using IntelliJ and JUnit version 5.5.2. I've imported the Test annotations without any problems but I cannot get assertEquals methods to be recognised.

I've tried the following imports:

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

The closest I got is wih the last line, but then I get an error "Cannot resolve method assertEquals". I am trying to test my method from another class that converts a binary number to decimal.

Here is the full code:

import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;


public class Einstiegsbeispieltest {

Einstiegsbeispiel testObject = new Einstiegsbeispiel();

@Test
public void testOne() {
assertEquals(14, testObject.binary2decimal(1110));
}
}

I've googled everywhere but no avail.

This method might be returning void instead of int. testObject.binary2decimal(1110));
please change method to return it to int.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM