>

안녕하세요들 TestNG를 사용하여 내 오이 프레임 워크를 실행하려고 메신저, 메신저 확신 버전 문제를 메신저하지만 누군가가 여기 덕분에 문제를 지적 할 수있는 경우 ID가 그것을 감사

기능 :

Feature: Application Login
Scenario: Home page default login
Given user is on landing page
When user logins into the application with username "jon" and password 
"1234"
Then Home page is displayed
And Cards displayed "true"
Scenario: Home page default login2
Given user is on landing page
When user logins into the application with username "john" and password 
"4321"
Then Home page is displayed
And Cards displayed "false"

정의 :

package StepDefinations;
import cucumber.api.PendingException;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.When;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.And;

public class LoginDefination {
    @Given("^user is on landing page$")
    public void user_is_on_landing_page() throws Throwable {
        //code
        System.out.println("on landing page");
        }

    @When("^user logins into the application with username and password$")
    public void user_logins_into_the_application_with_username_and_password() throws Throwable {
        //code
        System.out.println("logging in");
    }
    @When("^user logins into the application with username \"([^\"]*)\" and password \"([^\"]*)\"$")
    public void user_logins_into_the_application_with_something_and_password_something(String strArg1, String strArg2) throws Throwable {
        System.out.println(strArg1 +" "+ strArg2);
    }
    @Then("^Home page is displayed$")
    public void home_page_is_displayed() throws Throwable {
        //code
        System.out.println("hello homepage");
    }
    @And("^Cards are displayed$")
    public void cards_are_displayed() throws Throwable {
        //code
        System.out.println("hello cards");
    }
    @And("^Cards are not displayed$")
    public void cards_are_not_displayed() throws Throwable {
        //code
        System.out.println("hello not cards");
    }
    @And("^Cards displayed \"([^\"]*)\"$")
    public void cards_displayed(String args) throws Throwable {
        //code
        System.out.println("this will or will not display the cards - " + args);
    }
}

테스트 러너 파일 :

package CucumberOptions;
import cucumber.api.CucumberOptions;
import cucumber.api.testng.AbstractTestNGCucumberTests;
//Feature
@CucumberOptions(
        features = "src\\test\\java\\features",
        //if u want tp execute everything then just give the path till the package level
        glue= "StepDefinations"//Package name
        )
public class TestRunner extends AbstractTestNGCucumberTests {
}

testng xml 파일 :

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite">
  <test name="cucumber testing 101">
  <classes>
  <class name="CucumberOptions.testme"/>
  <class name="CucumberOptions.TestRunner"/>
  </classes>
  </test> <!-- Test -->
</suite> <!-- Suite -->

maven pom.xml 파일 :

<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>Cucumber</groupId>
  <artifactId>Automation</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>jar</packaging>
  <name>Automation</name>
  <url>http://maven.apache.org</url>

  <build>
  <resources>
 <resource>
        <directory>src/main/java/resources</directory>
        <filtering>true</filtering>
 </resource>
  </resources>
  <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.22.0</version>
        <configuration>
          <suiteXmlFiles>
            <suiteXmlFile>testng.xml</suiteXmlFile>
          </suiteXmlFiles>
        </configuration>
      </plugin>
</plugins>
  </build>
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>
  <dependencies>
  <!-- https://mvnrepository.com/artifact/info.cukes/cucumber-java -->
<dependency>
    <groupId>info.cukes</groupId>
    <artifactId>cucumber-java</artifactId>
    <version>1.2.5</version>
</dependency>

  <!-- https://mvnrepository.com/artifact/info.cukes/cucumber-testng -->
<dependency>
    <groupId>info.cukes</groupId>
    <artifactId>cucumber-testng</artifactId>
    <version>1.1.5</version>
</dependency>

  <dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-java</artifactId>
    <version>3.14.0</version>
</dependency>

<dependency>
    <groupId>org.testng</groupId>
    <artifactId>testng</artifactId>
    <version>6.10</version>
    <scope>test</scope>
</dependency> 


  </dependencies>
</project>

오류 :

[RemoteTestNG] detected TestNG version 6.10.0
org.testng.TestNGException: 
Cannot instantiate class CucumberOptions.TestRunner
    at org.testng.internal.ObjectFactoryImpl.newInstance(ObjectFactoryImpl.java:40)
    at org.testng.internal.ClassHelper.createInstance1(ClassHelper.java:363)
    at org.testng.internal.ClassHelper.createInstance(ClassHelper.java:275)
    at org.testng.internal.ClassImpl.getDefaultInstance(ClassImpl.java:126)
    at org.testng.internal.ClassImpl.getInstances(ClassImpl.java:191)
    at org.testng.TestClass.getInstances(TestClass.java:100)
    at org.testng.TestClass.initTestClassesAndInstances(TestClass.java:86)
    at org.testng.TestClass.init(TestClass.java:78)
    at org.testng.TestClass.<init>(TestClass.java:41)
    at org.testng.TestRunner.initMethods(TestRunner.java:425)
    at org.testng.TestRunner.init(TestRunner.java:252)
    at org.testng.TestRunner.init(TestRunner.java:222)
    at org.testng.TestRunner.<init>(TestRunner.java:171)
    at org.testng.remote.support.RemoteTestNG6_10$1.newTestRunner(RemoteTestNG6_10.java:28)
    at org.testng.remote.support.RemoteTestNG6_10$DelegatingTestRunnerFactory.newTestRunner(RemoteTestNG6_10.java:61)
    at org.testng.SuiteRunner$ProxyTestRunnerFactory.newTestRunner(SuiteRunner.java:623)
    at org.testng.SuiteRunner.init(SuiteRunner.java:189)
    at org.testng.SuiteRunner.<init>(SuiteRunner.java:136)
    at org.testng.TestNG.createSuiteRunner(TestNG.java:1375)
    at org.testng.TestNG.createSuiteRunners(TestNG.java:1355)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1209)
    at org.testng.TestNG.runSuites(TestNG.java:1133)
    at org.testng.TestNG.run(TestNG.java:1104)
    at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:114)
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at org.testng.internal.ObjectFactoryImpl.newInstance(ObjectFactoryImpl.java:29)
    ... 25 more
Caused by: java.lang.NoSuchMethodError: cucumber.runtime.RuntimeOptionsFactory.<init>(Ljava/lang/Class;[Ljava/lang/Class;)V
    at cucumber.api.testng.AbstractTestNGCucumberTests.<init>(AbstractTestNGCucumberTests.java:27)
    at CucumberOptions.TestRunner.<init>(TestRunner.java:14)
    ... 30 more

나는 매우 감사 할 것입니다 밖으로 누군가가 나를 도울 수 있다면

의 간단한 코드 조각 그러나 메신저 그냥, 그것을 받는다는 다음 TestNG를 사용하여 작업 할 수 있도록 노력 :)

  • 답변 # 1

    호환되지 않는 TestNG 및 Cucumber 라이브러리 버전. 검증 여기에 예를 들어 당신의 종속성 트리와 오이 라이브러리의 버전으로 어떤 TestNG를에 맞는 버전 체크에서 그들의 버전 :

    https://mvnrepository.com/artifact/info.cukes/cucumber-testng

    https://mvnrepository.com/artifact/io.cucumber/cucumber-testng

    업데이트 : 실제로 pom.xml 를 게시 한 것으로 나타났습니다.

    cucumber-testng 버전 업데이트   1.2.5 로  ( cucumber-java 와 동일한 버전을 사용하십시오. ). testng 사용  버전 6.9.10  (당신은 상관 없으면). 이렇게하면 모든 라이브러리 버전을 정렬 할 수 있습니다.

    확인 됨 : cucumber-testng 간에 충돌이 있습니다.  ver. 1.1.5와 cucumber-java  ver. 1.2.5. 두 라이브러리를 버전 1.1.5 로 설정하십시오. 버전 1.2.5 를 사용하도록 업데이트하십시오. .

  • 이전 css - jquery로 값이 없을 때 div를 숨기는 방법
  • 다음 c - 소켓 - 클라이언트의 ip 및 호스트 이름 표시