Skip to content

Commit

Permalink
Add pending feature test for issue #1593
Browse files Browse the repository at this point in the history
Co-authored-by: Leonard Brünings <[email protected]>
  • Loading branch information
Vampire and leonard84 authored Mar 10, 2023
1 parent 01a0583 commit 3abe3e6
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 7 deletions.
15 changes: 9 additions & 6 deletions spock-core/src/main/groovy/spock/util/EmbeddedSpecRunner.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package spock.util

import org.junit.platform.engine.Filter
import org.spockframework.runtime.*
import org.spockframework.util.*

Expand Down Expand Up @@ -77,10 +78,10 @@ class EmbeddedSpecRunner {
compiler.addClassMemberImport(clazz)
}


SummarizedEngineExecutionResults runWithSelectors(DiscoverySelector... selectors) {
runWithSelectors(asList(selectors))
}

SummarizedEngineExecutionResults runWithSelectors(List<DiscoverySelector> selectors) {
withNewContext {
doRunRequest(selectors)
Expand All @@ -93,9 +94,9 @@ class EmbeddedSpecRunner {
}
}

SummarizedEngineExecutionResults runClass(Class clazz) {
SummarizedEngineExecutionResults runClass(Class clazz, Filter<?>... filters) {
withNewContext {
doRunRequest([selectClass(clazz)])
doRunRequest([selectClass(clazz)], asList(filters))
}
}

Expand Down Expand Up @@ -128,15 +129,17 @@ class EmbeddedSpecRunner {
extensionClasses, configClasses, inheritParentExtensions, block as IThrowableFunction)
}

private SummarizedEngineExecutionResults doRunRequest(List<DiscoverySelector> selectors) {
def executionResults = doRunRequestInner(selectors)
private SummarizedEngineExecutionResults doRunRequest(List<DiscoverySelector> selectors, List<Filter<?>> filters = []) {
def executionResults = doRunRequestInner(selectors, filters)

return new SummarizedEngineExecutionResults(executionResults)
}
private EngineExecutionResults doRunRequestInner(List<DiscoverySelector> selectors) {

private EngineExecutionResults doRunRequestInner(List<DiscoverySelector> selectors, List<Filter<?>> filters = []) {
def executionResults = EngineTestKit
.engine("spock")
.selectors(*selectors)
.filters(*filters)
.execute()
if (throwFailure) {
def first = executionResults.allEvents().executions().failed().stream().findFirst()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@

package org.spockframework.smoke.extension

import org.junit.platform.engine.FilterResult
import org.junit.platform.engine.discovery.DiscoverySelectors

import org.junit.platform.launcher.PostDiscoveryFilter
import org.spockframework.EmbeddedSpecification
import spock.lang.Issue
import spock.lang.PendingFeature

class StepwiseSpecs extends EmbeddedSpecification {
def "basic usage"() {
Expand Down Expand Up @@ -66,6 +69,29 @@ class Foo extends Specification {
result.testsSkippedCount == 0
}

@PendingFeature
@Issue("https://github.com/spockframework/spock/issues/1593")
def "automatically runs excluded methods that lead up to an included method with post discovery filter"() {
def clazz = compiler.compileWithImports("""
@Stepwise
class Foo extends Specification {
def step1() { expect: true }
def step2() { expect: true }
def step3() { expect: true }
}
""")[0]

when:
def result = runner.runClass(clazz, {
FilterResult.includedIf(it.displayName == 'step3')
} as PostDiscoveryFilter)

then:
result.testsSucceededCount == 3
result.testsFailedCount == 0
result.testsSkippedCount == 0
}

def "honors method-level @Ignore"() {
runner.throwFailure = false

Expand Down

0 comments on commit 3abe3e6

Please sign in to comment.