What's new in YUI Test 3.1.0
- It was difficult to determine whether tests were still being executed or not.
- There was no easy way to extract the results of the tests.
TestRunnerinterface. The first method,
isRunning(), returns true when the TestRunner is in the middle of running tests and false otherwise. This enables easy usage with Selenium's
waitForCondition()method to determine when tests have completed. The second new method is
getResults(). While tests are being executed, this method always returns
null. Once tests are completed, this method returns an object containing all of the test result information. Optionally, you can pass in one of the test result formats (available on
Y.Test.Format) to return a string containing test result information in the specified format. For example:
This method also makes scripting with Selenium easier, as you're able to retrieve the test result information from your script in a usable format. Note: Selenium's scripting capabilities can only access objects in the global scope, so you'll need to make sure the
var results = Y.Test.Runner.getResults(Y.Test.Format.XML);
TestRunnerinstance is available globally.
New Results FormatsThere are a lot of tools that can take unit test results and produce reports. Prior to YUI 3.1.0, YUI Test supported only basic test result formats in XML and JSON. Although these could be transformed into other formats, it made sense to implement two other popular formats natively: JUnit XML and TAP. You can access the results in these new formats using
JUnit XML is one of the most widely supported test result formats amongst existing tools. Though its format doesn't map exactly to YUI Test structure (for example, there isn't a concept of nested test suites in JUnit XML), you still get enough information captured to make reasonable reports. TAP is a newer test results format that is free-form text. Unlike JUnit XML, TAP has no concept of grouping tests, and so YUI Test inserts comments into the output to identify test suites and test cases. To learn more about the new test formats, as well as to see example output, please see the Viewing Results section of the YUI Test documentation. These new formats can also be used with the already existing Test Reporting mechanism.
var junitXml= Y.Test.Runner.getResults(Y.Test.Format.JUnitXML); var tap = Y.Test.Runner.getResults(Y.Test.Format.TAP);