Jeff
Jeff

Reputation: 8421

Test is not an annotation type

in my maven project, i have added the testng dependency as below:

<!-- https://mvnrepository.com/artifact/org.testng/testng -->
<dependency>
    <groupId>org.testng</groupId>
    <artifactId>testng</artifactId>
    <version>7.1.0</version>
    <scope>test</scope>
</dependency>

But, then when i write a simple test as below, it cannot find @Test :

public class Test{


    @Test
    public void test() {

    }

}

it complains with Test is not an annotation type i tried to add the test manually by the below line:

import org.testng.annotations.Test;

but again it complains with:

The import org.testng.annotations.Test conflicts with a type defined in the same file

I have Forced Update my project by maven several times but still no success.

Upvotes: 1

Views: 9832

Answers (2)

Shekhar
Shekhar

Reputation: 1

Remove scope tag from respective dependency in pom.xml. It shall work.

Upvotes: 0

user13596679
user13596679

Reputation: 71

It is not working because your class name also the "Test" so, you have to change the class name then only @Test annotation will work.

Upvotes: 6

Related Questions