I added a JUnit jar to my classpath and it can easily find and run tests in the command window, but when I try to compile a test that I know, it cannot find anything to do with JUnit. I get the following error for each test class. I tested it on another computer, and it works, but not on mine. Any ideas?
EstateAgentTest.java:25: incompatible types found : Test required: java.lang.annotation.Annotation @Test public void rentable1() {
Many thanks.
Today I ran into this problem ...
Turns out calling my class name "Test.java" was a bad idea - it runs into the @Test line above your test method. To fix:
, , , , , , import org.junit.Test;, :
import org.junit.Test;
import org.junit.*; import org.junit.Test; import static org.junit.Assert.*;
, import org.junit.*;.
import org.junit.*;
, , , Java .
, java -version . , , 1,4 , 1,5.
java -version
I don't know if this will matter, but I'm used to seeing the @Test annotation above the declaration of the test method, for example:
@Test public void testSomething() { // }
My second guess is that another class file for Test imported somehow and not JUnit annotation.
It seems that you have a class Testsomewhere nearby and it has been imported. Try this code to make sure you are working with jUnit Testannotations:
Test
@org.junit.Test void testSomething(){
Source: https://habr.com/ru/post/1796480/More articles:Как получить доступ к данным в выбранной строке struts jquery grid plugin? - jquerywhy can't we override the base class method with the private extended class method? - javaIs there some kind of event to determine when DataGrid columns (i.e., Added, deleted) in Silverlight change? - c #Chrome extension: programmatic way to open popup.html from background.html? - javascriptAndroid - TTS missing voice - androidAdding a rule for jQuery validation plugin - jqueryCreating ctags working with CSS - cssHow to write bresenham algorithms in C #? - c #Perl regex question - regexIntegrating a third-party API into a Java application with conflicting dependencies - javaAll Articles