简体   繁体   English

RunListener结果方法

[英]RunListener result method

I have a class who extends RunListener. 我有一个扩展RunListener的类。

I would like to know the result of the method. 我想知道该方法的结果。 So in this method : 所以在这种方法中:

public void testFinished(Description description) throws java.lang.Exception {
    System.out.println("Finished execution of test case : " + description.getMethodName());
}

I would like something like : description.getResult(), but it doesn't existe. 我想要类似的东西:description.getResult(),但是它不存在。 How can I make ? 我该怎么做?

thanks. 谢谢。

Whatever methods you can use depends on the Description object. 可以使用的任何方法取决于Description对象。 If you want/need getResult() , you will have to implement that method in the Description class and make it public. 如果需要/需要getResult() ,则必须在Description类中实现该方法并将其公开。

Example: 例:

This is an example of the method you need to implement in your Description class. 这是您需要在Description类中实现的方法的示例。

public Object getResult() {
  // this is the method you need to implement, with whatever return type you need instead of Object (String etc.)
  return result;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM