Issue ISSUE = Issue.create(id,description,detail_description, Category.CORRECTNESS, Severity.ERROR, new Implementation(MyDetector.class, EnumSet.of(Scope.TEST_SOURCES)));
lint().files(java(SOURCE_CODE).issues(MyDetector.ISSUE).run().expect(expectedError);lint().files(
java( ... ),
// test/ prefix makes it a test folder entry:
java(
"test/my/pkg/UnitTest.java",
"""
package my.pkg;
public class UnitTest {
public void test() {
new ProductionCode().code(); // OK
new ProductionCode().testHelper1(); // OK
new ProductionCode().testHelper2(); // OK
}
}
"""
).indented(),
java( ... )
).run().expect(expected)
Thanks a lot Tor. Is it possible to target the lint rule to both test/ and androidTest/ folder? I found my lint rule does not seem to run in androidTest folder if I specify the scope TEST_SOURCES.
--
You received this message because you are subscribed to the Google Groups "lint-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lint-dev+u...@googlegroups.com.
To post to this group, send email to lint...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lint-dev/e5eda994-822c-4290-96b7-892184f16a60%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Thanks a lot Tor. Is it possible to target the lint rule to both test/ and androidTest/ folder? I found my lint rule does not seem to run in androidTest folder if I specify the scope TEST_SOURCES.
new Implementation(MyDetector.class, EnumSet.of(Scope.JAVA_FILES, Scope.TEST_SOURCES));new Implementation(MyDetector.class, EnumSet.of(Scope.TEST_SOURCES))
new Implementation(MyDetector.class, EnumSet.of(Scope.JAVA_FILES, Scope.TEST_SOURCES));
public UElement createUastHandler(@NonNull JavaContext context){
return new UElementHandler() {
@Override
public void visitXXXX(UExpression node) {
if (context.isTestSource()) {
context.report(XXXX);
}
}
}
}