4

タペストリーを使ったWebアプリを開発しています。junit テスト スイートを使用してアプリケーションをテストし、ant ビルドを使用して war ファイルと html レポートを生成しています。HTML レポート ファイルに、次の警告があります。

Multiple annotations found at this line:
    - Attribute (width) is obsolete. Its use is discouraged in HTML5 documents.
    - Attribute (cellpadding) is obsolete. Its use is discouraged in HTML5 
     documents.
    - Undefined attribute value (0). 
    - Attribute (language) is obsolete. Its use is discouraged in HTML5 documents.

以下は私のテストとレポート生成コードです。

<target name="test" depends="compile" description="Running Test Suite">
        <mkdir dir="${target.data.dir}"/>
        <mkdir dir="${target.htmlreports.dir}"/>
        <junit fork="no" haltonfailure="no" showoutput="yes" printsummary="true" >
        <test name="${junit.class.name}" todir="${target.data.dir}"/>
        <formatter type="brief" usefile="false"/>
        <classpath refid="classpath.test"/>
        <sysproperty key="ant.home" value="${ant.home}"/>   
        <formatter type="xml"/>
        </junit>
        <junitreport todir="${target.htmlreports.dir}">
        <fileset dir="${target.data.dir}">
        <include name="TEST-*.xml"/>
        </fileset>
        <report format="frames" todir="${target.htmlreports.dir}"/>
        </junitreport>
    </target>

これは、html レポート ファイルの 1 つです。

<html xmlns:lxslt="http://xml.apache.org/xslt" xmlns:stringutils="xalan://org.apache.tools.ant.util.StringUtils">
<head>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Unit Test Results: Summary</title>
<link rel="stylesheet" type="text/css" title="Style" href="stylesheet.css">
</head>
<body onload="open('allclasses-frame.html','classListFrame')">
<h1>Unit Test Results.</h1>
<table width="100%">
<tr>
<td align="left"></td><td align="right">Designed for use with <a href="http://www.junit.org/">JUnit</a> and <a href="http://ant.apache.org/">Ant</a>.</td>
</tr>
</table>
<hr size="1">
<h2>Summary</h2>
<table class="details" border="0" cellpadding="5" cellspacing="2" width="95%">
<tr valign="top">
<th>Tests</th><th>Failures</th><th>Errors</th><th>Success rate</th><th>Time</th>
</tr>
<tr valign="top" class="Pass">
<td><a title="Display all tests" href="all-tests.html">1</a></td><td><a title="Display all failures" href="alltests-fails.html">0</a></td><td><a title="Display all errors" href="alltests-errors.html">0</a></td><td>100.00%</td><td>0.070</td>
</tr>
</table>
<table border="0" width="95%">
<tr>
<td style="text-align: justify;">
        Note: <em>failures</em> are anticipated and checked for with assertions while <em>errors</em> are unanticipated.
        </td>
</tr>
</table>
<h2>Packages</h2>
<table class="details" border="0" cellpadding="5" cellspacing="2" width="95%">
<tr valign="top">
<th width="80%">Name</th><th>Tests</th><th>Errors</th><th>Failures</th><th nowrap>Time(s)</th><th nowrap>Time Stamp</th><th>Host</th>
</tr>
<tr valign="top" class="Pass">
<td><a href="./test/web/app/sampleApp/juint/package-summary.html">test.web.app.sampleApp.juint</a></td><td>1</td><td>0</td><td>0</td><td>0.070</td><td>2013-01-17T04:52:59</td><td>123456</td>
</tr>
</table>
</body>
</html>

この警告を削除する方法を教えてください。

4

9 に答える 9

3

私は同じ問題に直面しており、HTML 5 doctype の代わりに HTML 4.01 doc type を使用して解決策を得ました。これらの警告は、HTML5 バリデータのみが原因です

于 2013-08-08T08:12:36.730 に答える
2

これらの警告は HTML5 バリデーターからのものであり、使用しているツールはそのようなバリデーターをバックグラウンドで実行し、報告されたエラーの一部を警告として報告します。HTML ドキュメントで直接http://validator.nuを使用すると、他にも多くのエラー メッセージが表示されます。

「未定義の属性値 (0)」という警告。しかし、謎です。HTML5 バリデーターがこのように言うのは、おそらく奇妙な言い方<table border="0">です。表の枠線の太さを調整するには、代わりに CSS を使用してください。」</p> bordertable

使用しているツールに、生成された HTML ドキュメントで使用されるドキュメント タイプ (doctype) を制御するオプションがあるかどうか (報告された問題は、HTML5 ドラフトによるエラーであり、XHTML 1.0 などによるものではありません)、または生成された HTML コードの種類をチェックしてください。または問題の報告 (「警告なし」など)。ただし、可能であれば、警告を無効にするだけで、実際の問題が見えなくなる可能性があります。

于 2013-01-17T08:59:25.893 に答える
1

<html>タグの前に次のコードを含めるだけです。

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
于 2014-09-03T07:30:25.427 に答える
1

Kanhu の返信を詳しく説明するには、ここで Eclipse のデフォルトの HTML doctype を変更できます。

Project -> Properties -> Web Content 
于 2014-08-06T00:03:22.943 に答える
1

問題は、タペストリー コードではなく、html レポートにあります。生成された html レポートは、cellpadding、cellspacing などの現在廃止されている html 4 属性を使用します。これらは単なる junit テスト レポートです。私は彼らの html 警告に悩まされることはありません。

于 2013-01-17T05:40:31.880 に答える
0

使用できます

<table data-width="100%" class="config-header-font">

それ以外の

<table width="100%" class="config-header-font"> 

わたしにはできる。

注:警告は削除されますが、属性の配置位置が変更される可能性があります(確かではありません)。

于 2017-12-19T10:02:29.737 に答える