Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check @isTest classes are not abstract or virtual #223

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,12 @@ object ApexModifiers {
} else if (!outer && mods.contains(ISTEST_ANNOTATION)) {
logger.logError(idContext, s"isTest can only be used on outer classes")
mods.filterNot(_ == ISTEST_ANNOTATION)
} else if (
mods.contains(ISTEST_ANNOTATION) && (mods
.contains(ABSTRACT_MODIFIER) || mods.contains(VIRTUAL_MODIFIER))
) {
logger.logError(idContext, s"isTest classes can not be abstract or virtual")
mods.filterNot(_ == ISTEST_ANNOTATION)
} else {
mods
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,38 @@ class ClassModifierTest extends AnyFunSuite {
assert(legalClassAccess(ArraySeq(ISTEST_ANNOTATION)))
}

test("isTest and abstract modifier") {
val issues = illegalClassAccess(ArraySeq(ISTEST_ANNOTATION, ABSTRACT_MODIFIER))
assert(
issues == Seq[Issue](
Issue(
Path("Dummy.cls"),
diagnostics.Diagnostic(
ERROR_CATEGORY,
Location(1, 23, 1, 28),
"isTest classes can not be abstract or virtual"
)
)
)
)
}

test("isTest and virtual modifier") {
val issues = illegalClassAccess(ArraySeq(ISTEST_ANNOTATION, VIRTUAL_MODIFIER))
assert(
issues == Seq[Issue](
Issue(
Path("Dummy.cls"),
diagnostics.Diagnostic(
ERROR_CATEGORY,
Location(1, 22, 1, 27),
"isTest classes can not be abstract or virtual"
)
)
)
)
}

test("Abstract modifier") {
assert(legalClassAccess(ArraySeq(ABSTRACT_MODIFIER, PUBLIC_MODIFIER)))
}
Expand Down