JS Unite-Test
JS Unite-Test
QUnit
основные фичи:
- Легкая в изучении и использование
- Удобно тестировать локальный код на js
- Возможность тестирования асинхронный код
Полезные ссылки:
- http://qunitjs.com/ - официальная документация
- http://ruseller.com/lessons.php?rub=32&id=761 - хорошая статья, как писать тесты при помощи QUnit
JsTestDriver
основные фичи:
- Минимум настроек: только номер порта для сервера и пути к файлам браузеров (Firefox, Chrome, Safari, Internet Explorer и Opera) на локальном компьютере
- Запуск сервера и браузеров для тестирования прямо из IDE
- Простейший конфигурационный файл для запуска тестов (прописывается только URL тестового сервера и список необходимых javascript-файлов)
- Ручной запуск модульных тестов через меню Run
- Автоматический запуск модульных тестов при каждом изменении javascript-файлов
Полезные ссылки:
- http://code.google.com/p/js-test-driver/ - официальная документация
- http://meri-stuff.blogspot.ru/2012/01/javascript-testing-with-jstestdriver.html - хорошая статья, как писать тесты при помощи jsTestDriver
Download JsTestDriver
download link: http://code.google.com/p/js-test-driver/downloads/list
Project Configuration JsTestDriver
All used examples are available on Github.
Unless specified otherwise, js-test-driver expects configuration in current working directory in a file named jsTestDriver.conf
.
At minimum, the configuration file must contain:
- list of JavaScript files under test in section
load
, - list of JavaScript files containing test cases in section
test
.
The configuration file would look like this:
load:
- src/Utilities.js
- src/Core.js
- src/Main.js
test:
- src-test/TestsUtils.js
- src-test/*.js
Сonfiguration parameters:
Running Tests - Command Line
Start Server
Use the command java -jar JsTestDriver.jar --port <PORT_NUMBER> to start the server. The parameter port is mandatory, the server will listen on it.
java -jar JsTestDriver.jar --port 42442
Capture Browser
Open the browser and put http://<servers ip address>:<PORT_NUMBER>/capture
into URL bar.
http://127.0.0.1:42442/capture
The browser is now captured. Its top should have green color and contain something like this:
JsTestDriver
Last:1323466357645 | Next:1975 | Server:Waiting...
Start Both Server and Browsers
If you do not want to manually open each browser and edit its url, use the parameter --browser <browser 1>,<browser 2>,..., <browser n>
. It will start each listed browser and fill correct capture URL into it.
java -jar JsTestDriver.jar --port 42442 --browser "C:\Program Files (x86)\Mozilla Firefox\firefox.exe",C:\Users\AppData\Local\Google\Chrome\Application\chrome.exe,"C:\Program Files\Internet Explorer\iexplore.exe
Run Tests
The simplest possible way to run tests is the command java -jar JsTestDriver.jar --server <servers address:port> --tests all
.
It will read jsTestDriver.conf
file in the current directory, send all configured files to the browser and run all tests.
java -jar JsTestDriver.jar --server http://127.0.0.1:42442 --tests all
Simple Testing
Create simplest possible test case
All command line options are available on the projects wiki page.