Перейти к содержимому

Автоматизация функционального тестирования
онлайн, начало 1 октября
Английский для тестировщиков
онлайн, начало 4 октября
Автоматизатор мобильных приложений
онлайн, начало 6 октября
Тестирование безопасности
онлайн, начало 6 октября
Фотография

JUnit + Jupiter ошибка инициализации


  • Авторизуйтесь для ответа в теме
В теме одно сообщение

#1 pbezpal

pbezpal

    Активный участник

  • Members
  • PipPip
  • 79 сообщений
  • ФИО:Безпалько Павел

Отправлено 11 июля 2019 - 16:00

Всем привет!

 

Написал параметрический тест. Вроде все тестовые случаи проходит успешно, но почему-то ругается на инициализацию

 

Class WindowLoginParametersTest

package ru.minicom.itphone.client;

import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.ClassRule;
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.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 String className = Thread.currentThread().getStackTrace()[1].getClassName();

@ClassRule
public static StartingTest startTest = new StartingTest(className);

private static Process shell = null;

static {
try {
shell = startTest.getProcess();
} catch (IOException e) {
e.printStackTrace();
}
}

private static WebDriver driver = null;

static {
try {
driver = startTest.getWebDriver();
} catch (MalformedURLException e) {
e.printStackTrace();
}
}

private WindowLogin windowLogin = new WindowLogin(driver);

@ClassRule
public static FinishedTest finish = new FinishedTest(shell, className);

@Before
public void setUp() throws MalformedURLException {
startTest.getWebDriver();
Assert.assertNotNull("RemoteWebDriver не запущен...",driver);
}

@After
public void tearDown() {
windowLogin.clickYesExitConfirmForm();
Assert.assertFalse(windowLogin.isAvailableLoginWindow());
}

@Parameterized.Parameters(name = "{0}")
public static Collection<Character> data(){
ArrayList<Character> data = new ArrayList<>();

for (char c : str.toCharArray()) data.add(c);

return data;
}

@ParameterizedTest
@MethodSource("data")
public void testParameters(char symbol){
windowLogin.setLogin(Character.toString(symbol));
char[] rez = windowLogin.getLogin().toCharArray();
assertTrue(symbol == rez[0]);
}
}

Class StartingTest

package ru.minicom.itphone.client;

import org.junit.Assert;
import org.junit.rules.TestWatcher;
import org.junit.runner.Description;
import org.openqa.selenium.WebDriver;

import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;

public class StartingTest extends TestWatcher {

private StartTest start = new StartTest();
private Process shell = null;
private WebDriver driver = null;
private WindowLogin windowLogin = null;
private String login = start.getLogin();
private String password = start.getPassword();
private String server = start.getServer();
private String className;
private String profile = System.getProperty("user.home") + "\\AppData\\Roaming\\IT-Phone\\Profiles";;

public StartingTest(){}

public StartingTest(String className){
this.className = className;
}

@Override
public void starting(Description description){
try {
Assert.assertTrue("Севрер " + start.getServer() + " недоступен", start.pingServer());
} catch (IOException e) {
e.printStackTrace();
}

try {
shell = getProcess();
System.out.println("Process = " + shell);
} catch (IOException e) {
e.printStackTrace();
}

Assert.assertNotNull("Winium.Desktop.Driver не запущен...", shell);

if( ! className.contains("WindowLoginTest") || ! className.contains("WindowLoginParametersTest")){
try {
driver = getWebDriver();
System.out.println("Driver = " + driver);
} catch (MalformedURLException e) {
e.printStackTrace();
}

Assert.assertNotNull("RemoteWebDriver не запущен...",driver);

windowLogin = new WindowLogin(driver);
windowLogin.setDataFields(login, password, server);
windowLogin.clickEnterButton();
}else {
start.deleteFolderProfile(new File(profile));
}
}

public WebDriver getWebDriver() throws MalformedURLException {
return start.startClient();
}

public Process getProcess() throws IOException {
return start.RunWinum();
}

public String getLogin(){
return login;
}
}

CLass FinishedTest

package ru.minicom.itphone.client;

import org.junit.rules.TestWatcher;
import org.junit.runner.Description;

public class FinishedTest extends TestWatcher {

private WindowMain windowMain = null;
private Process shell = null;
private String login;
private String className;

public FinishedTest(WindowMain windowMain, Process shell, String login, String className){
this.windowMain = windowMain;
this.shell = shell;
this.login = login;
this.className = className;
}

public FinishedTest(Process shell, String className){
this.shell = shell;
this.className = className;
}

@Override
public void finished(Description description){
if( ! className.contains("WindowLoginTest") || ! className.contains("WindowLoginParametersTest")) if(windowMain.isAvailableIconAdditionalClientTree()) windowMain.clickExitButton();

if(shell != null) shell.destroy();
}

}

Ошибка

java.lang.Exception: No runnable methods


at org.junit.runners.BlockJUnit4ClassRunner.validateInstanceMethods(BlockJUnit4ClassRunner.java:191)
at org.junit.runners.BlockJUnit4ClassRunner.collectInitializationErrors(BlockJUnit4ClassRunner.java:128)
at org.junit.runners.ParentRunner.validate(ParentRunner.java:416)
at org.junit.runners.ParentRunner.<init>(ParentRunner.java:84)
at org.junit.runners.BlockJUnit4ClassRunner.<init>(BlockJUnit4ClassRunner.java:65)
at org.junit.runners.parameterized.BlockJUnit4ClassRunnerWithParameters.<init>(BlockJUnit4ClassRunnerWithParameters.java:27)
at org.junit.runners.parameterized.BlockJUnit4ClassRunnerWithParametersFactory.createRunnerForTestWithParameters(BlockJUnit4ClassRunnerWithParametersFactory.java:16)
at org.junit.runners.Parameterized.createRunnersForParameters(Parameterized.java:313)
at org.junit.runners.Parameterized.<init>(Parameterized.java:248)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:104)
at org.junit.vintage.engine.discovery.DefensiveAllDefaultPossibilitiesBuilder$DefensiveAnnotatedBuilder.buildRunner(DefensiveAllDefaultPossibilitiesBuilder.java:113)
at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:86)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
at org.junit.vintage.engine.discovery.DefensiveAllDefaultPossibilitiesBuilder.runnerForClass(DefensiveAllDefaultPossibilitiesBuilder.java:56)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.vintage.engine.discovery.ClassSelectorResolver.resolveTestClass(ClassSelectorResolver.java:66)
at org.junit.vintage.engine.discovery.ClassSelectorResolver.resolve(ClassSelectorResolver.java:47)
at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.lambda$resolve$2(EngineDiscoveryRequestResolution.java:129)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
at java.util.ArrayList$ArrayListSpliterator.tryAdvance(ArrayList.java:1359)
at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126)
at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:498)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:485)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:152)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:464)
at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.resolve(EngineDiscoveryRequestResolution.java:174)
at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.resolve(EngineDiscoveryRequestResolution.java:120)
at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.access$100(EngineDiscoveryRequestResolution.java:53)
at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution$DefaultContext.resolve(EngineDiscoveryRequestResolution.java:227)
at org.junit.vintage.engine.discovery.MethodSelectorResolver.resolveParentAndAddFilter(MethodSelectorResolver.java:56)
at org.junit.vintage.engine.discovery.MethodSelectorResolver.resolve(MethodSelectorResolver.java:40)
at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.lambda$resolve$2(EngineDiscoveryRequestResolution.java:138)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
at java.util.ArrayList$ArrayListSpliterator.tryAdvance(ArrayList.java:1359)
at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126)
at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:498)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:485)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:152)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:464)
at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.resolve(EngineDiscoveryRequestResolution.java:174)
at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.resolve(EngineDiscoveryRequestResolution.java:120)
at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.resolveCompletely(EngineDiscoveryRequestResolution.java:87)
at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.run(EngineDiscoveryRequestResolution.java:80)
at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolver.resolve(EngineDiscoveryRequestResolver.java:112)
at org.junit.vintage.engine.discovery.VintageDiscoverer.discover(VintageDiscoverer.java:42)
at org.junit.vintage.engine.VintageTestEngine.discover(VintageTestEngine.java:62)
at org.junit.platform.launcher.core.DefaultLauncher.discoverEngineRoot(DefaultLauncher.java:177)
at org.junit.platform.launcher.core.DefaultLauncher.discoverRoot(DefaultLauncher.java:164)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:128)
at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:69)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

 


  • 0

#2 pbezpal

pbezpal

    Активный участник

  • Members
  • PipPip
  • 79 сообщений
  • ФИО:Безпалько Павел

Отправлено 11 июля 2019 - 16:07

Разобрался, нужно было подгрузить в pom.xml 

<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>5.5.0</version>
<scope>test</scope>
</dependency>

  • 0


Программирование на С# для тестировщиков
онлайн
Автоматизатор мобильных приложений
онлайн
Selenium WebDriver: полное руководство
онлайн
Программирование на Python для тестировщиков
онлайн



Количество пользователей, читающих эту тему: 0

0 пользователей, 0 гостей, 0 анонимных

Яндекс.Метрика
Реклама на портале