1
4

1 回答 1

0

我已经编写了一个自定义 TestSystem 来实现这一点。关键是客户端构建器。

public class CustomClientBuilder extends SlimClientBuilder {
   public CustomClientBuilder(Descriptor descriptor) {
      super(descriptor);
   }

   @Override
   public SlimCommandRunningClient build() throws IOException {
       Object commandRunner = new MockCommandRunner(this.getExecutionLogListener());
           return new SlimCommandRunningClient((CommandRunner)commandRunner, this.determineSlimHost(), this.getSlimPort(),
            this.determineTimeout(), this.getSlimVersion(), this.determineSSL(),
            this.determineHostSSLParameterClass());
   }
}

在您的测试系统工厂中使用此客户端构建器:

public class CustomTestSystemFactory implements TestSystemFactory {
  private final SlimTableFactory slimTableFactory;
  private final CustomComparatorRegistry customComparatorRegistry;

  public CustomTestSystemFactory(SlimTableFactory slimTableFactory,
        CustomComparatorRegistry customComparatorRegistry) {
    this.slimTableFactory = slimTableFactory;
    this.customComparatorRegistry = customComparatorRegistry;
  }

  public final TestSystem create(Descriptor descriptor) throws IOException {
    SlimClientBuilder clientBuilder = new CustomClientBuilder(descriptor);
    SlimCommandRunningClient slimClient = clientBuilder.build();
    HtmlSlimTestSystem testSystem = new HtmlSlimTestSystem(clientBuilder.getTestSystemName(),
        slimClient, this.slimTableFactory.copy(), this.customComparatorRegistry);
    return testSystem;
  }
} 
于 2016-12-08T14:24:58.607 回答