mirror of
https://codeberg.org/PGPainless/sop-java.git
synced 2024-12-22 12:57:57 +01:00
Abort tests on UnsupportedOption
This commit is contained in:
parent
65945e0094
commit
2d4bc24c64
3 changed files with 38 additions and 0 deletions
|
@ -5,8 +5,11 @@
|
||||||
package sop.testsuite.operation;
|
package sop.testsuite.operation;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Named;
|
import org.junit.jupiter.api.Named;
|
||||||
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
import org.junit.jupiter.params.provider.Arguments;
|
import org.junit.jupiter.params.provider.Arguments;
|
||||||
import sop.SOP;
|
import sop.SOP;
|
||||||
|
import sop.testsuite.AbortOnUnsupportedOption;
|
||||||
|
import sop.testsuite.AbortOnUnsupportedOptionExtension;
|
||||||
import sop.testsuite.SOPInstanceFactory;
|
import sop.testsuite.SOPInstanceFactory;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
@ -15,6 +18,8 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
@ExtendWith(AbortOnUnsupportedOptionExtension.class)
|
||||||
|
@AbortOnUnsupportedOption
|
||||||
public abstract class AbstractSOPTest {
|
public abstract class AbstractSOPTest {
|
||||||
|
|
||||||
private static final List<Arguments> backends = new ArrayList<>();
|
private static final List<Arguments> backends = new ArrayList<>();
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
// SPDX-FileCopyrightText: 2024 Paul Schaub <vanitasvitae@fsfe.org>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
package sop.testsuite
|
||||||
|
|
||||||
|
import java.lang.annotation.Inherited
|
||||||
|
|
||||||
|
@Target(AnnotationTarget.TYPE)
|
||||||
|
@Retention(AnnotationRetention.RUNTIME)
|
||||||
|
@Inherited
|
||||||
|
annotation class AbortOnUnsupportedOption
|
|
@ -0,0 +1,21 @@
|
||||||
|
// SPDX-FileCopyrightText: 2024 Paul Schaub <vanitasvitae@fsfe.org>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
package sop.testsuite
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Assumptions
|
||||||
|
import org.junit.jupiter.api.extension.ExtensionContext
|
||||||
|
import org.junit.jupiter.api.extension.TestExecutionExceptionHandler
|
||||||
|
import sop.exception.SOPGPException
|
||||||
|
|
||||||
|
class AbortOnUnsupportedOptionExtension : TestExecutionExceptionHandler {
|
||||||
|
override fun handleTestExecutionException(context: ExtensionContext, throwable: Throwable) {
|
||||||
|
val testClass = context.requiredTestClass
|
||||||
|
val annotation = testClass.getAnnotation(AbortOnUnsupportedOption::class.java)
|
||||||
|
if (annotation != null && SOPGPException.UnsupportedOption::class.isInstance(throwable)) {
|
||||||
|
Assumptions.assumeTrue(false, "Test aborted due to: " + throwable.message)
|
||||||
|
}
|
||||||
|
throw throwable
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue