Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Info annotation #959

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions spock-core/src/main/java/spock/lang/FeatureInfo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright 2013 the original author or authors.
*
* 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.
*/

package spock.lang;

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



/**
* Allows attaching id, impact, component and frequency of failure along with any addional data.
* This can be used in ACC analysis and risk based testing
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface FeatureInfo {
String id() default "";
int impact() default 1;
int frequencyOfFailure() default 1;
String component() default "";
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@

package org.spockframework.example

import spock.lang.FeatureInfo
import spock.lang.Specification
import spock.lang.Unroll

/**
* @author Peter Niederwieser
*/
class FeatureUnrolling extends Specification {
@FeatureInfo(id = "4b873cc6-f204-4517-aa3a-93834963046c",impact = 6,frequencyOfFailure = 1,component = "Feature Unrolling")
def "without unrolling"() {
expect:
name.size() == length
Expand All @@ -31,7 +33,7 @@ class FeatureUnrolling extends Specification {
name << ["Kirk", "Spock", "Scotty"]
length << [4, 5, 6]
}

@FeatureInfo(id = "6cca6feb-8049-4d12-82fe-5534e41e311b",impact = 3,frequencyOfFailure = 1,component = "Feature Unrolling")
@Unroll
def "with unrolling"() {
expect:
Expand All @@ -41,7 +43,7 @@ class FeatureUnrolling extends Specification {
name << ["Kirk", "Spock", "Scotty"]
length << [4, 5, 6]
}

@FeatureInfo(id = "01fdbb08-7163-4a8a-a806-aad04f34406b",impact = 2,frequencyOfFailure = 1,component = "Feature Unrolling")
@Unroll("length of '#name' should be #length")
def "with unrolling and custom naming pattern"() {
expect:
Expand All @@ -51,4 +53,4 @@ class FeatureUnrolling extends Specification {
name << ["Kirk", "Spock", "Scotty"]
length << [4, 5, 6]
}
}
}