Skip to content

Commit cd74512

Browse files
committed
Implementing ability to run only tests that need local environment. Fixes issue 2884
1 parent 42d2e2c commit cd74512

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

java/client/test/org/openqa/selenium/testing/JUnit4TestBase.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
import org.openqa.selenium.environment.webserver.AppServer;
3838
import org.openqa.selenium.internal.WrapsDriver;
3939
import org.openqa.selenium.remote.RemoteWebDriver;
40-
import org.openqa.selenium.support.ui.ExpectedCondition;
4140
import org.openqa.selenium.support.ui.Wait;
4241
import org.openqa.selenium.support.ui.WebDriverWait;
4342
import org.openqa.selenium.testing.drivers.WebDriverBuilder;

java/client/test/org/openqa/selenium/testing/drivers/TestIgnorance.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,14 +143,17 @@ private static Platform getEffectivePlatform() {
143143
}
144144

145145
private boolean isIgnoredDueToBeingOnSauce(FrameworkMethod method, Object test) {
146-
return SauceDriver.shouldUseSauce() &&
147-
(method.getMethod().getAnnotation(NeedsLocalEnvironment.class) != null ||
148-
test.getClass().getAnnotation(NeedsLocalEnvironment.class) != null);
146+
boolean isLocal = method.getMethod().getAnnotation(NeedsLocalEnvironment.class) != null
147+
|| test.getClass().getAnnotation(NeedsLocalEnvironment.class) != null;
148+
if (SauceDriver.shouldUseSauce()) {
149+
return isLocal;
150+
} else {
151+
return Boolean.getBoolean("local_only") && !isLocal;
152+
}
149153
}
150154

151155
private boolean isIgnoredDueToJavascript(JavascriptEnabled enabled) {
152156
return enabled != null && !browser.isJavascriptEnabled();
153-
154157
}
155158

156159
private boolean isIgnoredDueToEnvironmentVariables(FrameworkMethod method, Object test) {

rake-tasks/crazy_fun/mappings/java.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,10 @@ def handle(fun, dir, args)
545545
ant.sysproperty :key => 'ignored_only', :value => 'true'
546546
end
547547

548+
if local_only?
549+
ant.sysproperty :key => 'local_only', :value => 'true'
550+
end
551+
548552
# Log levels can be any of {'DEBUG', 'INFO', 'WARNING', 'ERROR'}
549553
levels = Array.[]("INFO", "DEBUG", "WARNING", "ERROR")
550554
if log_level
@@ -651,6 +655,11 @@ def ignored_only?
651655
!([nil, 'false'].include? ENV['ignoredonly'])
652656
end
653657

658+
def local_only?
659+
# we set local_only true if the commandline argument is set and it is not 'false'
660+
!([nil, 'false'].include? ENV['localonly'])
661+
end
662+
654663
def leave_running?
655664
# we set leaverunning true if the commandline argument is set and it is not 'false'
656665
!([nil, 'false'].include? ENV['leaverunning'])

0 commit comments

Comments
 (0)