Skip to content

Commit

Permalink
Merge pull request #4 from gradle/leo/class-retry
Browse files Browse the repository at this point in the history
  • Loading branch information
leonard84 authored Dec 21, 2022
2 parents 57b777d + d8ba7e6 commit 8ff207a
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 0 deletions.
35 changes: 35 additions & 0 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -168,3 +168,38 @@ tasks.test {
}
}
----
==== Retry on class-level (since 1.1)
By default, individual tests are retried.
The classRetry component of the test retry extension can be used to control which test classes must be retried as a whole unit.
Test classes still have to pass the configured filter, as this annotation does not imply `@Retryable` by default.
The Test Retry Gradle plugin version 1.5.0 or higher has built-in support for `@ClassRetry`.
[source,kotlin]
----
tasks.test {
retry {
classRetry {
includeAnnotationClasses.add("com.gradle.enterprise.testing.annotations.ClassRetry")
}
}
}
----
===== Combining with Opt-in mode
You can also combine configure `@ClassRetry` act as opt-in marker.
[source,kotlin]
----
tasks.test {
retry {
filter {
includeAnnotationClasses.add("com.gradle.enterprise.testing.annotations.Retryable")
includeAnnotationClasses.add("com.gradle.enterprise.testing.annotations.ClassRetry")
}
}
}
----
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
*
* * Copyright 2022-2022 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 com.gradle.enterprise.testing.annotations;

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

/**
* Annotation to indicate that a test should be retried on the class level.
* <p>
* This annotation does not imply {@link Retryable} unless configured explicitly.
* <p>
* Works only in conjunction with the test <a href="https://github.com/gradle/test-retry-gradle-plugin">test-retry-gradle-plugin</a>.
*
* @since 1.1
*/
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface ClassRetry {
/**
* Optional reason for the usage. Purely for informational purposes.
*/
String because() default "";
}

0 comments on commit 8ff207a

Please sign in to comment.