From 50f04e43e2287cde67e5c8dfcbdd436be4ace84d Mon Sep 17 00:00:00 2001 From: Sergey Karashevich Date: Wed, 25 Apr 2018 13:54:13 +0300 Subject: [PATCH] [gui-test] fix GUI-65: do not override a timeout This fix allows to do not override a timeout specified for a test by a test rule (Timeout) with a GuiTestRule default timeout. It is not recommended to mix Timeout rule and parameter in a @Test annotation. --- .../testGuiFramework/impl/GuiTestRule.kt | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/platform/testGuiFramework/src/com/intellij/testGuiFramework/impl/GuiTestRule.kt b/platform/testGuiFramework/src/com/intellij/testGuiFramework/impl/GuiTestRule.kt index b2bb64f80c7a..30d03980a422 100644 --- a/platform/testGuiFramework/src/com/intellij/testGuiFramework/impl/GuiTestRule.kt +++ b/platform/testGuiFramework/src/com/intellij/testGuiFramework/impl/GuiTestRule.kt @@ -66,11 +66,16 @@ class GuiTestRule : TestRule { .around(myFatalErrorsFlusher) .around(IdeHandling()) .around(ScreenshotOnFailure()) - .around(Timeout(20, TimeUnit.MINUTES))!! + + private val timeoutRule = Timeout(20, TimeUnit.MINUTES) override fun apply(base: Statement?, description: Description?): Statement { myTestName = "${description!!.className}#${description.methodName}" - return myRuleChain.apply(base, description) + //do not apply timeout rule if it is already applied to a test class + return if (description.testClass.fields.any { it.type == Timeout::class.java }) + myRuleChain.apply(base, description) + else + myRuleChain.around(timeoutRule).apply(base, description) } fun robot(): Robot = myRobotTestRule.getRobot() @@ -148,9 +153,11 @@ class GuiTestRule : TestRule { fun isFirstStep(): Boolean { return try { - val actionLinkFixture = ActionLinkFixture.findActionLinkByName(CREATE_NEW_PROJECT_ACTION_NAME, robot(), welcomeFrameFixture.target(), tenSec) + val actionLinkFixture = ActionLinkFixture.findActionLinkByName(CREATE_NEW_PROJECT_ACTION_NAME, robot(), + welcomeFrameFixture.target(), tenSec) actionLinkFixture.target().isShowing - } catch (componentLookupException: ComponentLookupException) { + } + catch (componentLookupException: ComponentLookupException) { false } } @@ -287,7 +294,7 @@ class GuiTestRule : TestRule { val toSelect = VfsUtil.findFileByIoFile(projectPath, false) Assert.assertNotNull(toSelect) doImportProject(toSelect!!) -//TODO: add wait to open project + //TODO: add wait to open project return findIdeFrame(projectPath) }