今天使用junit做沒底時,報了一個提示!test is not an annotation type,在方法上加上@org.junit.Test就沒有問題,如下
import org.junit.Test;import redis.clients.jedis.Jedis;public class Test {@Test,此處提示Test is not an annotation typepublic void test_string() {Jedis jedis = new Jedis("localhost");System.out.PRintln("Connection to server successfully");jedis.set("mykey", "zosef");System.out.println("Server is running:"+jedis.get("mykey"));} }
仔細檢查了一下,類名也叫Test,結果是沖突了!暈了!改正后
import org.junit.Test;import redis.clients.jedis.Jedis;public class JedisTest { @Testpublic void test_string() {Jedis jedis = new Jedis("localhost");System.out.println("Connection to server successfully");jedis.set("mykey", "zosef");System.out.println("Server is running:"+jedis.get("mykey"));} }
新聞熱點
疑難解答