Tag Archives: Annotation type expected

How to Solve Annotation type expected error

Write an idea test class, use @Test, and then report an error. Possible reasons for the error are as follows:

1. First, check whether you are lazy and write the class name as test when creating the class

If the class name is test, it cannot be used, but the fully qualified name can be used.

2. The jar package version number used is too low

The @Test annotation can only be used in versions above junit4. If a lower version is used, the annotation method cannot be used.

3. The test folder is not set to test resource root

The setting method is as follows:

I haven’t encountered such a situation yet.

If none of the above methods can be solved, you can try to change the version of JUnit and try several more versions. Some people on the Internet say that the scope label needs to be deleted. This situation has not been encountered for the time being. I don’t know whether it is feasible. I can try it