0

I'm trying to create a unit test suite in IntelliJ however the @Test function is crossed out and say's it is depricated, and when I try run a simple test the console say's no tests were found.

    package test;
import assignment.Game;
import org.junit.Test;
import org.junit.After;
import org.junit.Before;
import org.junit.Assert;

public class NaughtsCrossesTest {

//Game game;

@Before
public void setUp() throws Exception {
    //game = new Game();
}

@After
public void tearDown() throws Exception {

}


@Test
public void testDiagonalWin() throws Exception{
    System.out.println("hello");
}

in the screenshot below you can see that test is crossed out

and it results in this happening

when i hover over test it says it is depricated (im new to java so dont know what that means) but offers no results in how to fix it. any help would be appreciated. I tried adding and removing throws exception out of the "testdiagaonalwin" function but that did nothing.

i'll just specify its java8 and junit4 i am using.

SOLVED: invalidated cache and restart fixed it

finH
  • 3
  • 5
  • First read this: https://stackoverflow.com/questions/15081610/what-does-it-mean-for-a-method-to-be-deprecated – Lukas Bradley Dec 11 '17 at 17:00
  • Second, what version of Java are you using, and more importantly, what version of JUnit are you using? – Lukas Bradley Dec 11 '17 at 17:01
  • java8 and junit4 – finH Dec 11 '17 at 17:02
  • What EXACT version of Junit 4 are you using? I don't think @Test is deprecated in any Junit 4 release.... – Lukas Bradley Dec 11 '17 at 17:08
  • when i click on external libraries it says "j unit-4.12.jar(library root)" and below that "junit4" - library root being faded out – finH Dec 11 '17 at 17:10
  • 2
    Can you try "Invalidate Cache / Restart" option in IntelliJ? – alayor Dec 11 '17 at 17:12
  • thank you alayor that fixed it!! appreciated – finH Dec 11 '17 at 17:14
  • After you try alayor advice, hover over the @Test annotation, and tell us what it says. If you hold down the CONTROL key and click on it, it should take you to the source (possibly decompiled). Tell us more about what you see. We're asking this because we think you probably have a classpath issue. The Test annotation should NOT be deprecated. – Lukas Bradley Dec 11 '17 at 17:15
  • thank you all for your help! – finH Dec 11 '17 at 17:21

0 Answers0