Всем привет!
Столкнулся с такой проблемой. Сделал параметризированные тесты
package ru.minicom.itphone.client; import org.junit.Assert; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.openqa.selenium.WebDriver; import java.io.File; import java.io.IOException; import java.net.MalformedURLException; import java.util.ArrayList; import java.util.Collection; import static junit.framework.Assert.assertTrue; @RunWith(Parameterized.class) public class WindowLoginParametersTest { //private static String str = "!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~ЂЃ‚ѓ„…†‡€‰Љ‹ЊЌЋЏђ‘’“”•–—™љ›њќћџ ЎўЈ¤Ґ¦§Ё©Є«¬®Ї°±Ііґµ¶·ё№є»јЅѕїАБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюяƒˆŠŒŽ˜šœžŸ¡¢£¥¨ª¯²³´¸¹º¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ"; public static String str = "!\"#$%&"; private static StartTest start = new StartTest(); private static Process shell = null; private static WebDriver driver = null; private static WindowLogin windowLogin = null; private static String profile = System.getProperty("user.home") + "\\AppData\\Roaming\\IT-Phone\\Profiles";; @BeforeAll public static void startTest(){ try { Assert.assertTrue("Севрер " + start.getServer() + " недоступен", start.pingServer()); } catch (IOException e) { e.printStackTrace(); } try { shell = start.RunWinum(); } catch (IOException e) { e.printStackTrace(); } Assert.assertNotNull("Winium.Desktop.Driver не запущен...", shell); start.deleteFolderProfile(new File(profile)); try { driver = start.startClient(); } catch (MalformedURLException e) { e.printStackTrace(); } Assert.assertNotNull("RemoteWebDriver не запущен...",driver); windowLogin = new WindowLogin(driver); } @Parameterized.Parameters(name = "{0}") public static Collection<Character> Symbols(){ ArrayList<Character> data = new ArrayList<>(); for (char c : str.toCharArray()) data.add(c); return data; } @Parameterized.Parameters(name = "{0}") public static Collection<String> Text(){ ArrayList<String> data = new ArrayList<>(); String tempStr = ""; for (char c : str.toCharArray()){ tempStr = tempStr + c; if(tempStr.length() > 32) break; data.add(tempStr); } return data; } /*@Parameterized.Parameters(name = "{0}") public static Collection<String> textServer(){ ArrayList<String> data = new ArrayList<>(); String tempStr = ""; for (char c : str.toCharArray()){ tempStr = tempStr + c; data.add(tempStr); } return data; }*/ @ParameterizedTest @MethodSource("Symbols") public void test_Symbols_Login(char symbol){ windowLogin.setLogin(Character.toString(symbol)); char[] rez = windowLogin.getLogin().toCharArray(); assertTrue(symbol == rez[0]); } @ParameterizedTest @MethodSource("Text") public void test_Text_Login(String text){ windowLogin.setLogin(text); assertTrue(text.equals(windowLogin.getLogin())); } /*@ParameterizedTest @MethodSource("Symbols") public void test_Symbols_Password(char symbol){ windowLogin.setPassword(Character.toString(symbol)); System.out.println("Password: " + windowLogin.getPassword()); char[] rez = windowLogin.getPassword().toCharArray(); assertTrue(symbol == rez[0]); }*/ @ParameterizedTest @MethodSource("Symbols") public void test_Symbols_Server(char symbol){ windowLogin.setServer(Character.toString(symbol)); char[] rez = windowLogin.getServer().toCharArray(); assertTrue(symbol == rez[0]); } /*@ParameterizedTest @MethodSource("textServer") public void test_Text_Server(String text){ windowLogin.setServer(text); assertTrue(text.equals(windowLogin.getServer())); }*/ @AfterAll public static void tearDown() { windowLogin.clickYesExitConfirmForm(); Assert.assertFalse(windowLogin.isAvailableLoginWindow()); if(shell != null) shell.destroy(); } }
Подключил необходимые библиотеки в maven
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>TestITPhoneClient</groupId> <artifactId>ru.minicom.itphone.client</artifactId> <version>1.0</version> <name>TestITPhoneClient</name> <url>http://maven.apache.org</url> <properties> <!--region General--> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <!--<java.version>11</java.version>--> <java.version>1.8</java.version> <!--endregion--> <!--region Libs --> <selenium-java.version>3.141.59</selenium-java.version> <sikulixapi.version>1.1.2</sikulixapi.version> <jadb.version>94ebf38</jadb.version> <junit.version>4.12</junit.version> <junit.jupiter.version>5.5.0</junit.jupiter.version> <junit.parameters.version>1.1.1</junit.parameters.version> <ant.version>1.10.6</ant.version> <!--endregion--> <!--region Plugins--> <maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version> <maven.compiler.source>${java.version}</maven.compiler.source> <maven.compiler.target>${java.version}</maven.compiler.target> <maven-jar-plugin.version>3.1.2</maven-jar-plugin.version> <!--endregion--> </properties> <repositories> <repository> <id>Mulesoft</id> <url>https://repository.mulesoft.org/nexus/content/repositories/public</url> </repository> </repositories> <dependencies> <dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-java</artifactId> <version>${selenium-java.version}</version> </dependency> <!-- https://mvnrepository.com/artifact/pl.pragmatists/JUnitParams --> <dependency> <groupId>pl.pragmatists</groupId> <artifactId>JUnitParams</artifactId> <version>${junit.parameters.version}</version> <scope>test</scope> </dependency> <!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api --> <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter-api</artifactId> <version>${junit.jupiter.version}</version> <scope>test</scope> </dependency> <dependency><!-- https://mvnrepository.com/artifact/com.sikulix/sikulixapi --> <groupId>com.sikulix</groupId> <artifactId>sikulixapi</artifactId> <version>${sikulixapi.version}</version> <exclusions> <exclusion> <groupId>com.github.vidstige</groupId> <artifactId>jadb</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>com.github.vidstige</groupId> <artifactId>jadb</artifactId> <version>${jadb.version}</version> </dependency> <!-- https://mvnrepository.com/artifact/org.apache.maven.surefire/surefire-junit4 --> <dependency> <groupId>org.apache.maven.surefire</groupId> <artifactId>surefire-junit4</artifactId> <version>3.0.0-M3</version> </dependency> <dependency> <groupId>io.appium</groupId> <artifactId>java-client</artifactId> <version>6.0.0</version> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>${junit.version}</version> <scope>test</scope> </dependency> <!-- https://mvnrepository.com/artifact/junit/junit-dep --> <!--<dependency> <groupId>junit</groupId> <artifactId>junit-dep</artifactId> <version>4.11</version> <type>pom</type> <scope>test</scope> </dependency>--> <!-- https://mvnrepository.com/artifact/org.junit/junit5-engine --> <dependency> <groupId>org.junit</groupId> <artifactId>junit5-engine</artifactId> <version>5.0.0-ALPHA</version> </dependency> <!-- https://mvnrepository.com/artifact/org.junit.platform/junit-platform-commons --> <dependency> <groupId>org.junit.platform</groupId> <artifactId>junit-platform-commons</artifactId> <version>1.5.0</version> </dependency> <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter-params</artifactId> <version>${junit.jupiter.version}</version> <scope>test</scope> </dependency> <!-- https://mvnrepository.com/artifact/org.junit.vintage/junit-vintage-engine --> <dependency> <groupId>org.junit.vintage</groupId> <artifactId>junit-vintage-engine</artifactId> <version>${junit.jupiter.version}</version> <scope>test</scope> </dependency> <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter-engine</artifactId> <version>5.5.0</version> <scope>test</scope> </dependency> <dependency> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-failsafe-plugin</artifactId> <version>3.0.0-M3</version> <scope>test</scope> </dependency> </dependencies> <build> <plugins> <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>${maven-compiler-plugin.version}</version> </plugin> <!--<plugin> <artifactId>maven-jar-plugin</artifactId> <version>${maven-jar-plugin.version}</version> <configuration> <archive> <manifest> <mainClass>ru.minicom.itphone.client.RunTests</mainClass> </manifest> </archive> </configuration> </plugin>--> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>3.0.0-M3</version> <configuration> <trimStackTrace>false</trimStackTrace> <includes> <include>**\WindowLoginTest.java</include> <include>**\WindowMainTest.java</include> <include>**\WindowSearchContactsTest.java</include> <include>**\WindowCallsTest.java</include> <!--<include>**\WindowLoginParametersTest.java</include>--> </includes> <!--<excludes> <exclude>**\NewTestClient.java</exclude> </excludes>--> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-failsafe-plugin</artifactId> <version>3.0.0-M3</version> <!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-failsafe-plugin --> <!--<dependencies> <dependency> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-failsafe-plugin</artifactId> <version>3.0.0-M3</version> <scope>test</scope> </dependency> </dependencies>--> </plugin> <plugin> <groupId>org.jvnet.maven-antrun-extended-plugin</groupId> <artifactId>maven-antrun-extended-plugin</artifactId> <dependencies> <dependency> <groupId>org.apache.ant</groupId> <artifactId>ant-junit</artifactId> <version>${ant.version}</version> </dependency> <dependency> <groupId>org.apache.ant</groupId> <artifactId>ant-trax</artifactId> <version>1.8.0</version> </dependency> </dependencies> <executions> <execution> <id>test-reports</id> <phase>test</phase> <configuration> <tasks> <junitreport todir="target/surefire-reports"> <fileset dir="target/surefire-reports"> <include name="**/*.xml" /> </fileset> <report format="noframes" todir="target/surefire-reports/html" /> </junitreport> <!--<tstamp> <format property="datetime" pattern="yyyyMMddHHmmss" /> </tstamp>--> <move file="target/surefire-reports/html/junit-noframes.html" tofile="target/surefire-reports/html/client-test-report.html" /> </tasks> </configuration> <goals> <goal>run</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </project>
Теперь при запуске тестов из консоли
mvn compile && mvn package -Dmaven.test.skip=true && mvn test
У меня вываливается сообщение об ошибке
[INFO] ------------------------------------------------------- [INFO] T E S T S [INFO] ------------------------------------------------------- июл 12, 2019 2:15:13 PM org.junit.platform.launcher.core.DefaultLauncher handleThrowable WARNING: TestEngine with ID 'junit-vintage' failed to discover tests org.junit.platform.commons.JUnitException: Failed to parse version of junit:junit: 3.8.1 at org.junit.vintage.engine.JUnit4VersionCheck.parseVersion(JUnit4VersionCheck.java:54) at org.junit.vintage.engine.JUnit4VersionCheck.checkSupported(JUnit4VersionCheck.java:37) at org.junit.vintage.engine.JUnit4VersionCheck.checkSupported(JUnit4VersionCheck.java:32) at org.junit.vintage.engine.VintageTestEngine.discover(VintageTestEngine.java:61) at org.junit.platform.launcher.core.DefaultLauncher.discoverEngineRoot(DefaultLauncher.java:168) at org.junit.platform.launcher.core.DefaultLauncher.discoverRoot(DefaultLauncher.java:155) at org.junit.platform.launcher.core.DefaultLauncher.discover(DefaultLauncher.java:120) at org.apache.maven.surefire.junitplatform.TestPlanScannerFilter.accept(TestPlanScannerFilter.java:56) at org.apache.maven.surefire.util.DefaultScanResult.applyFilter(DefaultScanResult.java:102) at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.scanClasspath(JUnitPlatformProvider.java:143) at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.invoke(JUnitPlatformProvider.java:124) at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:384) at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:345) at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:126) at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:418)