Statement (Statement base, FrameworkMethod method, Object target) { final PluginTargetVersions targetVersions = method.getAnnotation(PluginTargetVersions.class); if (method.getAnnotation(TargetVersions.class) != null && targetVersions != null) { throw new IllegalArgumentException( String.format("Annotations %s and %s could not be used together. ", TargetVersions.class.getName(), PluginTargetVersions.class.getName()) ); } TestWithKotlinPluginAndGradleVersions testCase = (TestWithKotlinPluginAndGradleVersions) target; if (targetVersions != null && !shouldRun(targetVersions, testCase)) { String mark = IS_UNDER_TEAMCITY ? "passed" : "ignored"; String message = "Test is marked " + mark + " due to unmet requirements\n" + "Gradle version: " + testCase.getGradleVersion() + " | Requirement: " + targetVersions.gradleVersion() + "\n" + "Plugin version: " + testCase.getKotlinPluginVersion() + " | Requirement: " + targetVersions.pluginVersion(); /* Tests are marked as successful on CI instead of Ignored, because this makes overall project maintainance easier (managing legitimately ignored tests). Running tests locally will still mark them as 'Ignored' */ if (IS_UNDER_TEAMCITY) { return new Statement() { @Override public void evaluate() { System.out.println(message); } }; } else { throw new AssumptionViolatedException(message); } } return base; }