From f664d87c6428baecee45f81d3f1a2e28d667d198 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Tue, 3 Sep 2013 10:14:00 +0300 Subject: [PATCH] Combine server name and test class into test name * Cleaned up integration test hierarchy * Corrected web socket test to actually use web sockets Change-Id: I33171026469ffaf3b79e50a56f6a1a682c0f2705 --- .../integration/IntegrationTestRunner.java | 61 +++++++++++++++ .../IntegrationTestStreamingTB3.java | 2 +- .../tests/integration/IntegrationTestTB3.java | 75 +++++++++++++++++++ .../IntegrationTestWebsocketTB3.java | 5 +- .../integration/IntegrationTestXhrTB3.java | 43 +---------- 5 files changed, 140 insertions(+), 46 deletions(-) create mode 100644 uitest/src/com/vaadin/tests/integration/IntegrationTestRunner.java create mode 100644 uitest/src/com/vaadin/tests/integration/IntegrationTestTB3.java diff --git a/uitest/src/com/vaadin/tests/integration/IntegrationTestRunner.java b/uitest/src/com/vaadin/tests/integration/IntegrationTestRunner.java new file mode 100644 index 0000000000..99e564e351 --- /dev/null +++ b/uitest/src/com/vaadin/tests/integration/IntegrationTestRunner.java @@ -0,0 +1,61 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +/** + * + */ +package com.vaadin.tests.integration; + +import org.junit.runners.BlockJUnit4ClassRunner; +import org.junit.runners.model.FrameworkMethod; +import org.junit.runners.model.InitializationError; + +/** + * JUnit runner for integration tests. + * + * @since + * @author Vaadin Ltd + */ +public class IntegrationTestRunner extends BlockJUnit4ClassRunner { + + private Class testClass; + + /** + * @param klass + * @throws InitializationError + */ + public IntegrationTestRunner(Class klass) throws InitializationError { + super(klass); + testClass = klass; + } + + /* + * (non-Javadoc) + * + * @see + * org.junit.runners.BlockJUnit4ClassRunner#testName(org.junit.runners.model + * .FrameworkMethod) + */ + @Override + protected String testName(FrameworkMethod method) { + if (IntegrationTestTB3.class.isAssignableFrom(testClass)) { + return testClass.getSimpleName() + "-" + + System.getProperty("server-name"); + } else { + return super.testName(method); + } + } +} diff --git a/uitest/src/com/vaadin/tests/integration/IntegrationTestStreamingTB3.java b/uitest/src/com/vaadin/tests/integration/IntegrationTestStreamingTB3.java index d5891f6fb5..9f5b92f5ff 100644 --- a/uitest/src/com/vaadin/tests/integration/IntegrationTestStreamingTB3.java +++ b/uitest/src/com/vaadin/tests/integration/IntegrationTestStreamingTB3.java @@ -1,6 +1,6 @@ package com.vaadin.tests.integration; -public class IntegrationTestStreamingTB3 extends IntegrationTestXhrTB3 { +public class IntegrationTestStreamingTB3 extends IntegrationTestTB3 { @Override protected Class getUIClass() { diff --git a/uitest/src/com/vaadin/tests/integration/IntegrationTestTB3.java b/uitest/src/com/vaadin/tests/integration/IntegrationTestTB3.java new file mode 100644 index 0000000000..dfdb1fed08 --- /dev/null +++ b/uitest/src/com/vaadin/tests/integration/IntegrationTestTB3.java @@ -0,0 +1,75 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +/** + * + */ +package com.vaadin.tests.integration; + +import java.io.IOException; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.openqa.selenium.WebElement; + +import com.vaadin.tests.tb3.PrivateTB3Configuration; + +/** + * + * @since + * @author Vaadin Ltd + */ +@RunWith(IntegrationTestRunner.class) +public class IntegrationTestTB3 extends PrivateTB3Configuration { + @Test + public void runTest() throws IOException, AssertionError { + compareScreen("initial"); + + WebElement cell = vaadinElement(getTableCell(getTable(), 0, 1)); + testBenchElement(cell).click(51, 13); + + compareScreen("finland"); + } + + private String getTableCell(String tableLocator, int row, int col) { + return tableLocator + + "/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[" + + row + "]/domChild[" + col + "]/domChild[0]"; + } + + protected String getTable() { + return "/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]"; + } + + @Override + protected String getPath() { + return "/demo" + super.getPath(); + } + + @Override + protected String getBaseURL() { + return System.getProperty("deployment.url"); + } + + @Override + protected String getTestName() { + // Note that this is used for screenshots. The test name shown in the + // build server and when running the JUnit test is produced by + // IntegrationTestRunner + return super.getTestName() + "-" + System.getProperty("server-name"); + } + +} diff --git a/uitest/src/com/vaadin/tests/integration/IntegrationTestWebsocketTB3.java b/uitest/src/com/vaadin/tests/integration/IntegrationTestWebsocketTB3.java index bce4744053..ad7ea09350 100644 --- a/uitest/src/com/vaadin/tests/integration/IntegrationTestWebsocketTB3.java +++ b/uitest/src/com/vaadin/tests/integration/IntegrationTestWebsocketTB3.java @@ -1,10 +1,9 @@ package com.vaadin.tests.integration; - -public class IntegrationTestWebsocketTB3 extends IntegrationTestXhrTB3 { +public class IntegrationTestWebsocketTB3 extends IntegrationTestTB3 { @Override protected Class getUIClass() { - return com.vaadin.tests.integration.IntegrationTestStreaming.class; + return com.vaadin.tests.integration.IntegrationTestWebsocket.class; } } diff --git a/uitest/src/com/vaadin/tests/integration/IntegrationTestXhrTB3.java b/uitest/src/com/vaadin/tests/integration/IntegrationTestXhrTB3.java index a49a0c2cdf..d17b7b7a88 100644 --- a/uitest/src/com/vaadin/tests/integration/IntegrationTestXhrTB3.java +++ b/uitest/src/com/vaadin/tests/integration/IntegrationTestXhrTB3.java @@ -1,51 +1,10 @@ package com.vaadin.tests.integration; -import java.io.IOException; - -import org.junit.Test; -import org.openqa.selenium.WebElement; - -import com.vaadin.tests.tb3.PrivateTB3Configuration; - -public class IntegrationTestXhrTB3 extends PrivateTB3Configuration { - - @Test - public void runTest() throws IOException, AssertionError { - compareScreen("initial"); - - WebElement cell = vaadinElement(getTableCell(getTable(), 0, 1)); - testBenchElement(cell).click(51, 13); - - compareScreen("finland"); - } - - private String getTableCell(String tableLocator, int row, int col) { - return tableLocator - + "/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[" - + row + "]/domChild[" + col + "]/domChild[0]"; - } - - protected String getTable() { - return "/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]"; - } +public class IntegrationTestXhrTB3 extends IntegrationTestTB3 { @Override protected Class getUIClass() { return IntegrationTestUI.class; } - @Override - protected String getPath() { - return "/demo" + super.getPath(); - } - - @Override - protected String getBaseURL() { - return System.getProperty("deployment.url"); - } - - @Override - protected String getTestName() { - return super.getTestName() + "-" + System.getProperty("server-name"); - } } -- 2.39.5