<commit_before>= Extensions

Spock comes with a powerful extension mechanism, which allows to hook into a spec's lifecycle to enrich or alter its
behavior. In this chapter, we will first learn about Spock's built-in extensions, and then dive into writing custom
extensions.

== Built-In Extensions

Most of Spock's built-in extensions are _annotation-driven_. In other words, they are triggered by annotating a
spec class or method with a certain annotation. You can tell such an annotation by its +@ExtensionAnnotation+
meta-annotation.

=== Ignore

To temporarily prevent a feature method from getting executed, annotate it with +spock.lang.Ignore+:

[source,groovy]
----
@Ignore
def "my feature"() { ... }
----

For documentation purposes, a reason can be provided:

[source,groovy]
----
@Ignore(reason = "TODO")
def "my feature"() { ... }
----

To ignore a whole specification, annotate its class:

[source,groovy]
----
@Ignore
class MySpec extends Specification { ... }
----

In most execution environments, ignored feature methods and specs will be reported as "skipped".

=== IgnoreRest

To ignore all but a (typically) small subset of methods, annotate the latter with +spock.lang.IgnoreRest+:

[source,groovy]
----
def "I'll be ignored"() { ... }

@IgnoreRest
def "I'll run"() { ... }

def "I'll also be ignored"() { ... }
----<commit_msg>Fixed example of "@Ignore with reason"<commit_after>= Extensions

Spock comes with a powerful extension mechanism, which allows to hook into a spec's lifecycle to enrich or alter its
behavior. In this chapter, we will first learn about Spock's built-in extensions, and then dive into writing custom
extensions.

== Built-In Extensions

Most of Spock's built-in extensions are _annotation-driven_. In other words, they are triggered by annotating a
spec class or method with a certain annotation. You can tell such an annotation by its +@ExtensionAnnotation+
meta-annotation.

=== Ignore

To temporarily prevent a feature method from getting executed, annotate it with +spock.lang.Ignore+:

[source,groovy]
----
@Ignore
def "my feature"() { ... }
----

For documentation purposes, a reason can be provided:

[source,groovy]
----
@Ignore("TODO")
def "my feature"() { ... }
----

To ignore a whole specification, annotate its class:

[source,groovy]
----
@Ignore
class MySpec extends Specification { ... }
----

In most execution environments, ignored feature methods and specs will be reported as "skipped".

=== IgnoreRest

To ignore all but a (typically) small subset of methods, annotate the latter with +spock.lang.IgnoreRest+:

[source,groovy]
----
def "I'll be ignored"() { ... }

@IgnoreRest
def "I'll run"() { ... }

def "I'll also be ignored"() { ... }
----
{'fraction_non_alphanumeric': 0.1187315634218289, 'fraction_numerical': 0.0, 'mean_word_length': 3.844642857142857, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5483004', 'n_tokens_mistral': 799, 'n_tokens_neox': 756, 'n_words': 340}