簡體   English   中英

無法在Eclipse中運行Testng批注

[英]Unable to run testng annotations in Eclipse

我試圖通過在Eclipse編輯器(在ubuntu os中)中實現一個簡單程序來理解testng框架的工作。 我的源代碼和pom xml定義如下:

TestExample.java

package test;

import org.testng.annotations.AfterSuite;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Test;

@Test(suiteName = "test suite for annotation")
public class TestExample {


    @BeforeSuite
    public void setup() {
        System.out.println("before test");
    }


    @AfterSuite
    public void finish() {
        System.out.println("After test");
    }

    @Test(description = "Test to save student", priority = 0)
    public void testSaveStudent() {
        System.out.println();
        System.out.println("Testing.....");
        System.out.println();

    }

}

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>com.nithin.exmple</groupId>
  <artifactId>TestingExample</artifactId>
  <version>0.0.1-SNAPSHOT</version>


    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.19.1</version>
                <configuration>
                    <testFailureIgnore>true</testFailureIgnore>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <dependencies>

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

    </dependencies>

</project>

但是在執行時,我的Eclipse編輯器無法提供預期的輸出(它正在呈現我最近運行的程序的輸出)。 我已經在IntelliJ IDE上執行了相同的程序,從而給出了預期的結果。

安裝TestNg插件-testng.org/doc/eclipse.html

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM