Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.4k views
in Technique[技术] by (71.8m points)

spring - Spock Stepwise - Keep running testsuite after single failure

When using the Spock @Stepwise annotation, is there any way to configure it to not fail the entire testsuite after a single test fails?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Decided to just create a new extension called @StepThrough. All I needed to do was subclass StepwiseExtension and take out the line of code that was failing the entire test suite. Pasted code below...

StepThrough.groovy

package com.test.SpockExtensions

import org.spockframework.runtime.extension.ExtensionAnnotation

import java.lang.annotation.ElementType
import java.lang.annotation.Retention
import java.lang.annotation.RetentionPolicy
import java.lang.annotation.Target

/**
 * Created by jchertkov on 6/22/15.
 */
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@ExtensionAnnotation(StepThroughExtension.class)
public @interface StepThrough {}

StepThroughExtension.groovy

package com.test.SpockExtensions

import org.spockframework.runtime.extension.builtin.StepwiseExtension
import org.spockframework.runtime.model.SpecInfo

import java.lang.annotation.Annotation

/**
 * Created by jchertkov on 6/22/15.
 */
public class StepThroughExtension extends StepwiseExtension {
    public void visitSpecAnnotation(Annotation annotation, final SpecInfo spec) {
        sortFeaturesInDeclarationOrder(spec);
        includeFeaturesBeforeLastIncludedFeature(spec);
    }
}

Notes:

  • I put the code into a package called com.test.SpockExtensions. You will need to do the same with whatever name you would like.
  • Java users - just change filetype from .groovy to .java

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...