Unit Tests

Nick Schonning edited this page Aug 16, 2013 · 2 revisions

Most parts of CSS Lint have unit tests associated with them. Unit tests are written using YUI Test and are required when making contributions to formatters, rules, or the core library. You'll find all of the unit tests in the tests directory.

When you first get the source code, you need to run grunt concat once initially to generate all of the code and the tests. Once you've done that, there are two ways to run the unit tests:

  1. Browser: Locate the testrunner.htm file in the tests directory. Load this into any web browser and click the "Run Tests" button. This executes all tests and prints out the results.
  2. Command Line: Run grunt from the command line to run all tests. When running grunt test, this automatically builds the rest of the library, so there's no need to run grunt concat beforehand.

Because CSS Lint is designed to work in any JavaScript environment, tests should be run both in the browser and on the command line to ensure compatibility.