From 55649bb6ec9c658aa568f035488c0afc0e04d535 Mon Sep 17 00:00:00 2001 From: Sapan Parikh Date: Mon, 17 Dec 2018 11:41:30 +0530 Subject: [PATCH 1/3] An annotation, FeatureInfo, to add information about some of the basic test attributes. This annotation then can be integrated with Spock Reports to add the following 1. Id (Need to identify every feature uniquely) 2. Impact (Impact of the feature, if it fails) 3. Frequency of Failure (Probability of a feature failing) 4. Component (Which component it may be associated with. Example: shopping cart, product page etc ) These params then cab be used to create reports like ACC (https://testing.googleblog.com/2011/10/google-test-analytics-now-in-open.html) --- .../src/main/java/spock/lang/FeatureInfo.java | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 spock-core/src/main/java/spock/lang/FeatureInfo.java diff --git a/spock-core/src/main/java/spock/lang/FeatureInfo.java b/spock-core/src/main/java/spock/lang/FeatureInfo.java new file mode 100644 index 0000000000..bc4e855528 --- /dev/null +++ b/spock-core/src/main/java/spock/lang/FeatureInfo.java @@ -0,0 +1,36 @@ +/* + * 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 to 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 ""; + String[] additionalInfo() default {}; +} From 55b5fffd1df97c2f8a7a5fc85d8411c9c79ec771 Mon Sep 17 00:00:00 2001 From: Sapan Parikh Date: Mon, 17 Dec 2018 13:08:33 +0530 Subject: [PATCH 2/3] Removing additional info array field --- spock-core/src/main/java/spock/lang/FeatureInfo.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/spock-core/src/main/java/spock/lang/FeatureInfo.java b/spock-core/src/main/java/spock/lang/FeatureInfo.java index bc4e855528..c87929c809 100644 --- a/spock-core/src/main/java/spock/lang/FeatureInfo.java +++ b/spock-core/src/main/java/spock/lang/FeatureInfo.java @@ -22,7 +22,7 @@ /** - * Allows to attaching id, impact, component and frequency of failure along with any addional data. + * 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) @@ -32,5 +32,4 @@ int impact() default 1; int frequencyOfFailure() default 1; String component() default ""; - String[] additionalInfo() default {}; } From 009d9648f9650c7f233a1d7c609332c95b4877d4 Mon Sep 17 00:00:00 2001 From: Sapan Parikh Date: Mon, 17 Dec 2018 13:10:44 +0530 Subject: [PATCH 3/3] Adding feature info annotation to test cases. --- .../org/spockframework/example/FeatureUnrolling.groovy | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/spock-specs/src/test/groovy/org/spockframework/example/FeatureUnrolling.groovy b/spock-specs/src/test/groovy/org/spockframework/example/FeatureUnrolling.groovy index 644aecd4f1..ec310bf0be 100644 --- a/spock-specs/src/test/groovy/org/spockframework/example/FeatureUnrolling.groovy +++ b/spock-specs/src/test/groovy/org/spockframework/example/FeatureUnrolling.groovy @@ -16,6 +16,7 @@ package org.spockframework.example +import spock.lang.FeatureInfo import spock.lang.Specification import spock.lang.Unroll @@ -23,6 +24,7 @@ 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 @@ -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: @@ -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: @@ -51,4 +53,4 @@ class FeatureUnrolling extends Specification { name << ["Kirk", "Spock", "Scotty"] length << [4, 5, 6] } -} \ No newline at end of file +}