Could not find class in Junit-4.11

前端 未结 2 1721
我寻月下人不归
我寻月下人不归 2021-01-06 08:40

I configured Junit-4.11 on my Mac, compile with javac has no error, but when I run with java, I got Could not find class: HelloWorldTest

2条回答
  •  旧时难觅i
    2021-01-06 09:32

    Ok I tested the same. Will provide the steps for the same:

    /
    |
    |--HelloWorld.java
    |--HelloWorldTest.java
    

    First process HelloWorld.java:

    javac HelloWorld.java
    

    This will result in HelloWorld.class in the same folder.

    Next process HelloWorldTest.java:

    javac -classpath C:\Himanshu_Work\repo\junit\junit\4.10\junit-4.10.jar;. HelloWorldTest.java
    

    This will result in HelloWorldTest.class in the same folder.

    java -classpath C:\Himanshu_Work\repo\junit\junit\4.10\junit-4.10.jar;. org.junit.runner.JUnitCore  HelloWorldTest
    JUnit version 4.10
    @BeforeClass - oneTimeSetUp
    .@Before - setUp
    @Test - testOutput
    @After - tearDown
    @AfterClass - oneTimeTearDown
    
    Time: 0
    
    OK (1 test)
    

提交回复
热议问题