2

私はそのようなHTMLテストスイートを実行しています:

java -jar /var/lib/selenium/selenium-server.jar -browserSessionReuse -htmlSuite *firefox http://$HOST ./test/selenium/html/TestSuite.html ./target/selenium/html/TestSuiteResults.html

ディレクトリ内のすべてのテスト スイートを実行したり、テスト スイートのテスト スイートを作成したりする方法はありますか?

4

3 に答える 3

0

スーパーテストスイートを自動的に作成する grails スクリプトを作成しました。テスト スイートを変更する必要があるということは、テストを追加するためのもう 1 つのステップであり、障壁の各レベルによって、開発者がテストの作成を拒否する可能性が高くなります。

import groovy.io.FileType

includeTargets << grailsScript("Init")

target(main: "Auto-generates the TestSuite.html file needed for selenium based on selenium html tests in test/selenium/html/**") {
    File testSuiteOutputFile = new File("test/selenium/html/TestSuite.html")
    testSuiteOutputFile.delete()

    String testRows = buildTestRows()
    testSuiteOutputFile << 
"""
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <meta content="text/html; charset=UTF-8" http-equiv="content-type" />
  <title>Test Suite</title>
</head>
<body>
<table id="suiteTable" cellpadding="1" cellspacing="1" border="1" class="selenium"><tbody>
<tr><td><b>Test Suite</b></td></tr>
$testRows
</tbody></table>
</body>
</html>
"""


}

private def buildTestRows() {
    String testRows = ""
    List<File> testFiles = getAllTestFilesInSeleniumDirectory()
    testFiles.each { file ->
        def relativePath = buildFilePathRelativeToTestSuite(file)
        println "Adding $relativePath to TestSuite"
        testRows += "<tr><td><a href='${relativePath}'>${file.name}</a></td></tr>"
        testRows += "<tr><td><a href='clearCache.html'>Clear Cache</a></td></tr>"
    }
    testRows
}

private List<File> getAllTestFilesInSeleniumDirectory() {
    File testsDirectory = new File("test/selenium/html")
    def files = []
    testsDirectory.eachFileRecurse(FileType.FILES) { files << it }
    files
}

private String buildFilePathRelativeToTestSuite(File file){
    File parentDirectory = new File("test/selenium/html")

    String relativePath = file.name
    file = file.parentFile
    while( file != parentDirectory ){
        relativePath = file.name + "/" + relativePath;
        file = file.parentFile
    }
    relativePath
}

setDefaultTarget(main)
于 2011-08-06T02:35:09.020 に答える
0

セルユニットを見てください。Selenese スイートをバッチで実行し、レポートを Junit 形式に変換する Maven プラグインを提供します。最後のものは、テスト実行を Jenkins のような CI サーバーに統合するのに非常に役立ちます。Jenkins は、テスト エラーの場合に優れたチャートを生成し、通知します。

于 2011-08-19T23:13:42.337 に答える
0

私はSeleniumに非常に慣れておらず、実際にはSelenium2のみです。テスト フレームワークとして「TestNG」を使用していますが、特定の注釈を含むどのテストがスイートの一部であるかを指定する xml ファイルを使用して、スイートおよびスイートのスイートをサポートしています。

スイートのスイートを実行することが探していて、Java のみを使用している場合 (私の理解では、TestNG は Java 以外をサポートしていません)、探しているものが見つかるかもしれません。

于 2011-08-05T16:57:03.420 に答える