Open
Description
This error will be thrown when we try to start a test but a session is never created
java.lang.NullPointerException
at com.saucelabs.saucebindings.SauceSession.updateResult(SauceSession.java:59)
at com.saucelabs.saucebindings.SauceSession.stop(SauceSession.java:54)
at com.saucelabs.saucebindings.SauceSession.stop(SauceSession.java:50)
at com.saucedemo.SauceConnectTest.teardown(SauceConnectTest.java:39)
This is the test to reproduce it
public class SauceConnectTest {
protected WebDriver driver;
private SauceSession session;
@Test
public void shouldOpen() {
SauceOptions options = new SauceOptions();
// When we start a tunnel, we provide a tunnedIdentifier using the '-i' flag
// And we can reference that tunnel here
options.setTunnelIdentifier("NikolaysTunnel");
session = new SauceSession(options);
driver = session.start();
// This is an example of an application that Sauce Labs cannot get to because it's in your internal network
// In order for Sauce to be able to Securely access your application, we use Sauce Connect
driver.get("http://localhost:3000");
assertEquals("React App", driver.getTitle());
}
@After
public void teardown() {
session.stop(true);
}
}
The reason this test fails is because no such tunnel identifier exists. Rather than throw a NullReference, we should do a check in our code.