Skip to content

Commit

Permalink
2.0.4: Fixed issue when using Capture with BeforeClass method.
Browse files Browse the repository at this point in the history
  • Loading branch information
ham1 committed Jun 27, 2016
1 parent 5c7747d commit 1826f17
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>com.frameworkium</groupId>
<artifactId>Frameworkium-core</artifactId>
<version>2.0.4-SNAPSHOT</version>
<version>2.0.4</version>

<name>Frameworkium-core</name>
<description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class SauceLabsListener extends SauceOnDemandTestListener {

private static final Logger logger = LogManager.getLogger();

private boolean isRunningOnSauceLabs = Sauce.isDesired();
private static final boolean isRunningOnSauceLabs = Sauce.isDesired();

@Override
public void onStart(ITestContext testContext) {
Expand Down
21 changes: 18 additions & 3 deletions src/main/java/com/frameworkium/core/ui/tests/BaseTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,23 @@ public static void instantiateDriverObject() {
capture = ThreadLocal.withInitial(() -> null);
}

public static void configureBrowserBeforeUse() {
configureBrowserBeforeTest(null);
/**
* Find the calling method and pass it into
* {@link #configureBrowserBeforeTest(Method)} to configure the browser.
*/
protected static void configureBrowserBeforeUse() {
Method method = getCallingMethod(Thread.currentThread().getStackTrace()[2]);
configureBrowserBeforeTest(method);
}

private static Method getCallingMethod(StackTraceElement stackTraceElement) {
String className = stackTraceElement.getClassName();
String methodName = stackTraceElement.getMethodName();
try {
return Class.forName(className).getDeclaredMethod(methodName);
} catch (ClassNotFoundException | NoSuchMethodException e) {
throw new RuntimeException(e);
}
}

/**
Expand Down Expand Up @@ -108,7 +123,7 @@ private static String determineUserAgent() {
* @param testMethod Test method passed from the test script
*/
private static void initialiseNewScreenshotCapture(Method testMethod) {
if (ScreenshotCapture.isRequired() && testMethod != null) {
if (ScreenshotCapture.isRequired()) {
Optional<String> testID = TestIdUtils.getIssueOrTestCaseIdValue(testMethod);
if (testID.orElse("").isEmpty()) {
logger.warn("{} doesn't have a TestID annotation.", testMethod.getName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,20 @@
import com.frameworkium.core.common.retry.RetryFlakyTest;
import com.frameworkium.core.ui.tests.BaseTest;
import com.frameworkium.integration.angularjs.pages.web.DeveloperGuidePage;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import ru.yandex.qatools.allure.annotations.TestCaseId;

import static com.google.common.truth.Truth.assertThat;

public class DocumentationTest extends BaseTest {

@BeforeClass
public void test_configure_browser_before_use() {
configureBrowserBeforeUse();
DeveloperGuidePage.open();
}

@Test(description =
"Tests the AngularJS developer documentation and search function",
retryAnalyzer = RetryFlakyTest.class)
Expand Down

0 comments on commit 1826f17

Please sign in to comment.