1

我有一个设置,我在 Maven 构建期间运行 JBehave 测试。

测试步骤包括使用 SoapUI Java 类向 Web 服务发送请求。

一切正常,testwise。我的问题是进度的 SoapUI 部分似乎覆盖了 log4j 设置,因此后续的日志调用不会打印到控制台(也不会打印到文件)。

我已经尝试过我打电话的解决方法

    ClassLoader loader = this.getClass().getClassLoader();
    URL resource = loader.getResource("log4j.xml");
    PropertyConfigurator.configure(resource);

尝试将配置重置为我原来的配置,但到目前为止没有成功。

Log4j (1.2) 和 SoapUI (4.5.1) 在 pom.xml 中使用普通设置。记录器被创建为 protected final Log log = LogFactory.getLog(getClass());

我得到的控制台输出如下:

    pool-1-thread-1 16:36:08,212 DEBUG ästeps.LoginSteps:25 - logging in user: testfir
    pool-1-thread-1 16:36:08,213 DEBUG äpages.LoginPage:26 - Create LoginPage
    pool-1-thread-1 16:36:08,985 DEBUG äpages.LoginPage:38 - login user: testfir
    pool-1-thread-1 16:36:10,343 DEBUG äpages.WorkspacePage:36 - creating WorkspacePage
    Givet user testfir has logged in
    16:36:11,634 WARN  [SoapUI] Missing folder [D:\proj\src\test\functional-tests\.\ext] for external libraries
    16:36:11,809 INFO  [DefaultSoapUICore] initialized soapui-settings from [C:\Users\xxx\soapui-settings.xml]
    16:36:12,176 INFO  [WsdlProject] Loaded project from [file:/D:/proj/src/test/functional-tests/src/test/resources/ReceiveCase-soapui.xml]
    16:36:12,640 DEBUG [HttpClientSupport$SoapUIHttpClient] Attempt 1 to execute request
    16:36:12,640 DEBUG [SoapUIMultiThreadedHttpConnectionManager$SoapUIDefaultClientConnection] Sending request: POST /soa-infra/services/default/ReceiveCases/ReceiveCase_v1_0_ep HTTP/1.1
    16:36:13,841 DEBUG [SoapUIMultiThreadedHttpConnectionManager$SoapUIDefaultClientConnection] Receiving response: HTTP/1.1 200 OK
    16:36:13,842 DEBUG [HttpClientSupport$SoapUIHttpClient] Connection can be kept alive indefinitely
    And a case exists
    When case is choosen
    16:36:46,832 DEBUG [SoapUIMultiThreadedHttpConnectionManager$SoapUIDefaultClientConnection] Connection closed
    Then the details are displyed

我期待一个日志输出

将案例 ID 设置为:123456

以与“创建登录页面”相同的方式。

无法理解这是为什么以及如何使我的日志条目显示出来。有什么想法吗?

最好的问候,克里斯蒂安

4

1 回答 1

0

设法找到问题的根源。是 Maven 扭曲了文件编码。添加

    <configuration>
      <encoding>UTF-8</encoding>
      <inputEncoding>UTF-8</inputEncoding>
      <outputEncoding>UTF-8</outputEncoding>
      <argLine>-Dfile.encoding=UTF-8</argLine>
    </configuration>

pom文件中的maven-surefire-plugin部分解决了我的问题。

/干杯

于 2013-01-23T13:36:18.890 回答