[junit 5] slow tests to be skipped locally

GitOrigin-RevId: e1cf400cd62ab64cad703e98550ab11aed5726a6
This commit is contained in:
Anna Kozlova
2021-12-22 11:45:31 +01:00
committed by intellij-monorepo-bot
parent 9789b5b05d
commit f6e9a3d020
2 changed files with 25 additions and 15 deletions

View File

@@ -0,0 +1,20 @@
// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.idea.extensions;
import com.intellij.testFramework.SkipSlowTestLocally;
import org.junit.jupiter.api.extension.ConditionEvaluationResult;
import org.junit.jupiter.api.extension.ExecutionCondition;
import org.junit.jupiter.api.extension.ExtensionContext;
import org.junit.platform.commons.support.AnnotationSupport;
public class SkipSlowExecutionCondition implements ExecutionCondition {
private static final ConditionEvaluationResult ENABLED = ConditionEvaluationResult.enabled("Enabled locally");
private static final ConditionEvaluationResult DISABLED = ConditionEvaluationResult.disabled("Slow tests are disabled locally");
private static final boolean SKIP_SLOW_TESTS = System.getProperty("skip.slow.tests.locally") != null;
@Override
public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context) {
if (!SKIP_SLOW_TESTS) return ENABLED;
return AnnotationSupport.findAnnotation(context.getTestClass(), SkipSlowTestLocally.class).isPresent() ? DISABLED : ENABLED;
}
}

View File

@@ -1,20 +1,9 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.testFramework;
import com.intellij.idea.extensions.SkipSlowExecutionCondition;
import org.junit.jupiter.api.extension.ExtendWith;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -26,4 +15,5 @@ import java.lang.annotation.Target;
*/
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@ExtendWith(SkipSlowExecutionCondition.class)
public @interface SkipSlowTestLocally { }