小编tha*_*ran的帖子

如何手动为 junit xml 报告创建 html 报告?

我已经运行了 junit 并且它在 Junit 控制台中显示了结果,然后我导出了结果,它被保存为一些 test.xml。现在我想从中生成一个 html 报告,我该怎么做?我的项目很复杂,我不能正常做

<target name ="test" depends="run-tests">
    <junitreport todir="${reports}">
        <fileset dir="${reports}/raw/">
            <include name="TEST-*.xml"/>
        </fileset>
        <report format="frames" todir="${reports}\html\"/>
    </junitreport>
</target>
Run Code Online (Sandbox Code Playgroud)

任何可用于将 xml 中的结果转换为 html 格式的任何工具。

html xml junit report

5
推荐指数
2
解决办法
1万
查看次数

如果存在断言错误,则Junit报告不会生成报告

如果存在要测试的断言错误类,则Junit报告不会生成报告

public class Math {

    static public int add(int a, int b) {

        return a + b;
    }

    static public int multiply ( int a, int b) {
        if(a==0&&b==0)
            return 0;;
        return a * b;
    }
}
Run Code Online (Sandbox Code Playgroud)

Junit测试课

import junit.framework.*;

public class TestMath extends TestCase { 

  protected void setUp() { 

    // put common setup code in here
   }

  protected void tearDown() {

    // put common cleanup code in here
  }

  public void testAdd() {
    int num1 = 3;
    int num2 …
Run Code Online (Sandbox Code Playgroud)

ant junit automated-tests reporting unit-testing

5
推荐指数
1
解决办法
1891
查看次数

java中的executeUpdate()需要很长时间才能执行

我使用一段简单的代码更新Oracle DB中的单行,查询只更新了一行,但执行仍然挂起在stmt.executeUpdate()上.

它不会抛出任何异常,但控件只是挂在那里.

我迷失在这里,因为同一段代码早先工作正常.

  try {
      DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());
      conn = DriverManager.getConnection(url,username,pwd);
      stmt = conn.createStatement();
      String sql = "update report set status =" +"'"+NO+"'"+ " where name=" +"'"+ name+"'"+ " and user_id=" +"'"+sub+"'"; 
      System.out.println(sql);          
      stmt.executeUpdate(sql)
Run Code Online (Sandbox Code Playgroud)

java sql oracle jdbc

4
推荐指数
1
解决办法
1万
查看次数

Java Xpath查询

如何使用Java Xpath获取第二个"c"标记d和f的值为2

<a>
    <b>
        <c type="lol">
            <d>1</d>
            <f>2</f>
        </c>
        <c type="lol">
            <d>2</d>
            <f>2</f>
        </c>
            <c type="h">
            <d>v</d>
            <f>d</f>
        </c>
    </b>
</a>

 { 
    DocumentBuilderFactory dBFactory = DocumentBuilderFactory.newInstance();
  DocumentBuilder dB = dBFactory.newDocumentBuilder();
  Document doc = dB.parse(url);     
  System.out.println("Root element :" + doc.getDocumentElement().getNodeName());
  XPathFactory factory = XPathFactory.newInstance();
  XPath xpath = factory.newXPath();
  XPathExpression expr=null;
  String text= null;
  expr= xpath.compile("//a/b/c[@type='lol']/d/text()");// this gets the first value
  text = (String) expr.evaluate(doc, XPathConstants.STRING);
     } 
Run Code Online (Sandbox Code Playgroud)

如何使用Java Xpath获取第二个"c"标记d和f的值为2

java xml tags xpath

2
推荐指数
1
解决办法
851
查看次数

标签 统计

java ×2

junit ×2

xml ×2

ant ×1

automated-tests ×1

html ×1

jdbc ×1

oracle ×1

report ×1

reporting ×1

sql ×1

tags ×1

unit-testing ×1

xpath ×1