ECMAScript proposals that reach Stage 2.7 in the TC39 Process need to have sufficient tests integrated to the Test262 test suite. To track the added tests, ensure that they are complete, and to get an idea of the amount of work needed, it's often helpful to have a testing plan outlining what exactly should be tested.
This document is a guide intended to help proposal authors and test262 contributors create such testing plans. It includes detailed instructions for contributors less familiar with test262 testing or less familiar with composing a testing plan, as well as a checklist that may also be helpful to contributors more experienced with Test262 tests and testing plans.
In the end of this document, in addition to the checklist, there are also some links with further material.
If you are looking for an ECMAScript proposal to write a testing plan for, we try to have open issues asking for testing plans, for proposals in Stage 2.7 or 3. You can also see the TC39 document tracking the status of all the open proposals, in case we missed something, in which case please create the missing testing plan issue.
Before you start it's wise to communicate with proposal champion(s) in case they already have a testing plan and/or tests ready.
Understand the proposal text:
If you're unfamiliar with ECMAScript spec text, read this guide on how to read the ECMAScript Specification.
Read the proposal's rendered specification.
Finally, list all the separate tests that need to be written, as explained in the following sections.
For new APIs, you can start by listing some standard tests, such as the following.
this that is not what what it expects, via Function.prototype.apply or .call. ExampleList the various success cases that result in a normal completion:
List failure cases, when an exception is thrown:
? appears, indicating that what follows may throw an exception.U key to see who calls the related parts of the code, and check for unexpected entry points.Finally, consider testing the order of the algorithm steps, if there are steps that introduce side effects. However, it's best to not overdo it here. The goal is to help implementations correctly implement the new functionality. Exhaustively testing the order of side effects can lead to diminishing returns.
A testing plan for new syntax is similar to that for a new API but additionally:
Check what engines test, in case you missed something. Some engines' test locations in their codebase:
Finally, if you don‘t understand why a certain part of the spec is the way it is, it helps to git blame the file spec.html of the proposal’s Git repository. You may find linked PRs pointing to related issues, potentially with test cases that cover that part of the spec.
undefined, null, symbolsAs important as it is to have a complete testing plan, it is equally important to avoid diminishing returns and to understand when to stop adding cases to be tested. Especially when new specification algorithms call on existing algorithms, it may be temping to dive in the existing algorithms to explore the different paths they may take. However it is best to focus on writing more surface tests for these cases, and only dive in the nested algorithms when the proposal is expecting these to be relevant to the new additions.
On this topic it may be helpful to go through the discussion on the Testing Plan issue for Math.sumPrecise, and Mike Pennisi's testing plan guide for WPT.
- [ ]).Math.sumPrecise. https://github.com/tc39/test262/issues/4054