Testng-为所有数据提供者运行测试方法后如何运行清除代码?

时间:2018-09-30 06:39:03

标签: java testng

我有一个testng测试(如下),其中我对数据提供者“ junkDP”给出的每个数组使用一个“ totalAmount”值。我想重置“ totalAmount”,仅在为“ junkDP”中的每个数组运行“测试”方法之后。在testng中这可能吗?怎么做?

请注意,@AfterMethod和@AfterTest不能满足我的要求。 @AfterMethod在“ junkDP”中的第一个数组之后为每个数组运行“测试”方法之前,重置“ totalAmount”。 @AfterTest在@AfterClass之后运行。

代码:

`timescale 1ns/1ns
module counter(x_in,clk,y_out);
    input [31:0] x_in;
    input clk;
    output [31:0] y_out;
    reg [31:0] y_out;
    reg [31:0] temp;

    initial begin
        #1 temp=x_in;
    end

    always@(posedge clk) begin
        temp<=temp+1;   
        y_out<=temp;
    end
endmodule

输出:

`timescale 1ns/1ns

module testbench_conter();
    wire [31:0]y_out;
    wire [31:0]temp;
    reg [31:0]x_in;
    reg clk;

    counter C(x_in,clk,y_out);

    always begin
        #5 clk=~clk;
    end

    initial begin
        clk=1'b0; 
        x_in=32'd0;
        #0
        #10000
        $stop;
    end
endmodule

1 个答案:

答案 0 :(得分:0)

如果我理解这个问题,您是在测试方法之后搜索执行程序吗?

...如果是,取决于测试跑步者

在这里,testng的工作方式如何:

  

http://testng.org/doc/documentation-main.html#annotations

@AfterTest或@AfterMethod

相关问题