Reputation: 8951
I have the following code:
package osu.cs362.URLValidator;
import static org.junit.Assert.*;
import org.junit.Test;
import java.util.*;
import static org.mockito.Mockito.*;
public class DomainValidatorTest {
RegexValidator rev = mock(RegexValidator.class);
}
This includes the package osu.cs362.URLValidator
which contains RegexValidator
.
However, when running mvn test
I get:
cannot find symbol class RegexValidator
Why can't it find this class? Is this a pom.xml
issue?
Upvotes: 1
Views: 1377
Reputation: 131326
It is not a Maven problem.
If the RegexValidator
class had the declaration like that :
package osu.cs362.URLValidator;
public class RegexValidator {
...
}
you would have not the problem. So I suppose it is not the case.
Besides, filesytem folders are not Java packages.
For example, nobody prevents you from declaring your class in the folder :
osu/cs362
of your classpath folder and declaring the package of the class like that: fictive.folder
.
The class will compile.
It is the case for DomainValidatorTest
. The package is not symmetric with the folder layout but the class is found by the compiler and it doesn't cause a compilation error.
But of course, it is a bad practice and it is misleading. That's why packages should always be symmetric to the folders layout.
Upvotes: 1
Reputation: 8487
You shoud move your DomainValidatorTest.java
to directory:
src/test/java/osu/cs362/URLValidator
Directory structure should be the same as java package.
Upvotes: 1