# ===================================================================================== # This PowerShell script runs the Community Server functional tests using Selenium. # NOTES: # - Requires the Java runtime be installed and added to the PATH environment variable. # - We're using a patched build of the Selenium .jar file, as seen below. # ===================================================================================== # Get params, most likely passed from a .bat file. param($browser, $testScriptsRootDir, $reportDir, $tidyDir) # Setup pairs of test suites with their report names. Ex: ("myTestSuite.html", "myTestReport.html"). $suites = ("CommunityServer\Forums\P0\ForumCRUD\ForumCRUDP0TestSuite.html", "ForumCRUDP0.html"), ("CommunityServer\Forums\P0\PostCRUD\PostCRUDP0TestSuite.html", "PostCRUDP0.html"), ("CommunityServer\Forums\P0\TopicCRUD\TopicCRUDP0TestSuite.html", "TopicCRUDP0.html"), ("CommunityServer\Forums\P0\BrowseByTags\BrowseByTagsTestSuite.html", "BrowseByTags.html"), ("CommunityServer\Blogs\P0\BlogsCRUD\BlogCRUDP0TestSuite.html", "BlogCRUDP0.html"), ("CommunityServer\Wikis\P0\WikiCRUD\WikiCRUDP0TestSuite.html", "WikiCRUDP0.html") $accumulatedTestCount = 0 $accumulatedTestPasses = 0 $accumulatedTestFails = 0 $suitesWithFailures = @() foreach ($testSuiteAndReport in $suites) { $testSuite = $testSuiteAndReport[0] $testReport = $testSuiteAndReport[1] $testSuitePath = join-path $testScriptsRootDir $testSuite $testReportPath = join-path $reportDir $testReport "Running $testSuitePath..." $buildScriptDir = join-path $testScriptsRootDir "BuildScripts" set-location $buildScriptDir java -jar selenium-server-1.0-SNAPSHOT-standalone-TelligentPatched.jar -htmlSuite $browser http://localhost/csfunctionaltests/ $testSuitePath $testReportPath "Cleaning up HTML..." set-location $tidyDir ./tidy.exe -m -i --doctype omit --output-xml true --numeric-entities true $testReportPath $report = [xml] (get-content $testReportPath) $currentSuite = $report.SelectSingleNode("//table[@id='suiteTable']/tbody/tr[1]/td/b") $currentTestCount = $report.html.body.table[0].tr[2].td[1] $accumulatedTestCount += $currentTestCount $currentPasses = $report.html.body.table[0].tr[3].td[1] $accumulatedTestPasses += $currentPasses $currentFails = $report.html.body.table[0].tr[4].td[1] $accumulatedTestFails += $currentFails if ($currentFails -gt 0) { "`nFailures present: " + $currentSuite.get_InnerText() $suitesWithFailures += $currentSuite.get_InnerText() } } "Total Tests: " + $accumulatedTestCount "Total Passing: " + $accumulatedTestPasses "Total Failing: " + $accumulatedTestFails "Building Selenium report..." $xmlOut = "`n" $xmlOut += "" + $accumulatedTestCount + "`n" $xmlOut += "" + $accumulatedTestPasses+ "`n" $xmlOut += "" + $accumulatedTestFails+ "`n" $xmlOut += "`n" "Suites with failures:" foreach ($failure in $suitesWithFailures) { $xmlOut += "" + $failure + "`n" "* " + $failure } $xmlOut += "`n" $xmlOut += "`n" $finalReport = join-path $reportDir "selenium-results.xml" $xmlOut | out-file $finalReport