@@ -50,13 +50,23 @@ public static void setupProject() throws Exception
5050 {
5151 BaseUpgradeTest currentTest = BaseWebDriverTest .getCurrentTest ();
5252
53+ Class <?> testClass = currentTest .getClass ();
54+ String earliestVersion = Optional .ofNullable (testClass .getAnnotation (EarliestVersion .class ))
55+ .map (EarliestVersion ::value ).orElse (null );
56+ String latestVersion = Optional .ofNullable (testClass .getAnnotation (LatestVersion .class ))
57+ .map (LatestVersion ::value ).orElse (null );
58+
59+ Assume .assumeTrue ("Test class not valid when upgrading from version: " + setupVersion ,
60+ VersionRange .versionRange (earliestVersion , latestVersion ).contains (setupVersion )
61+ );
62+
5363 if (isUpgradeSetupPhase )
5464 {
5565 currentTest .doSetup ();
5666 }
5767 else
5868 {
59- TestLogger .info ("Skipping setup for %s. Verifying upgrade." . formatted (currentTest . getClass () .getSimpleName ()));
69+ TestLogger .info ("Skipping setup for %s. Verifying upgrade." . formatted (testClass .getSimpleName ()));
6070 }
6171 }
6272
@@ -100,19 +110,19 @@ protected boolean wasSetupWithin(String earliestVersion, String latestVersion)
100110 * Specifies the earliest version of the test class that performed the required setup for the annotated method.
101111 */
102112 @ Retention (RetentionPolicy .RUNTIME )
103- @ Target ({ElementType .METHOD })
113+ @ Target ({ElementType .METHOD , ElementType . TYPE })
104114 protected @interface EarliestVersion
105115 {
106116 String value ();
107117 }
108118
109119 /**
110- * Annotates test methods that should only run when upgrading from particular LabKey versions, as specified in
111- * {@code webtest.upgradePreviousVersion}.<br>
112- * Specifies the latest version of the test class that performed the required setup for the annotated method.
120+ * Annotates test methods or classes that should only run when upgrading from particular LabKey versions, as
121+ * specified in {@code webtest.upgradePreviousVersion}.<br>
122+ * Specifies the latest version of the test class that performed the required setup for the annotated method or class .
113123 */
114124 @ Retention (RetentionPolicy .RUNTIME )
115- @ Target ({ElementType .METHOD })
125+ @ Target ({ElementType .METHOD , ElementType . TYPE })
116126 protected @interface LatestVersion {
117127 String value ();
118128 }
0 commit comments