Glace (fr. glacé — ice, frozen) is a cold drink based on coffee with addition of ice cream.
glace-core
is a quick-start functional & unit testing framework based on mochajs and can be extented with its plugins.
Why it is
- Firstly it's R&D project for me to dive deeply to programming and software architecture.
- Current testing frameworks like mochajs or jasminejs look cool for unit testing but are not flexible for complex functional scenarios.
Quick start
Make sure you have installed
node >= v8.9
&npm >= v5.5
.Install
glace-core
globallynpm i -g glace-core
or locallynpm i glace-core
.Create file
tests.js
with next content:"use strict"; test("My first test", () => { chunk(() => { console.log("hello world"); }); }); test("My second test", () => { chunk(() => { throw new Error("BOOM!"); }); });
Launch tests with command
glace tests.js
if you installedglace-core
globally or with./node_modules/glace-core/bin/glace tests.js
if locally and get the result.
Features
- Cross-platform: can be launched easily in linux, macos, windows.
- Concept is based on STEPS-architecture.
- Plugins system based on STEPS-protocol.
- Parameterization inside and outside of test
- Mechanism to launch tests in parallel workers.
- Mechanism to retry failed tests
- Mechanism to retry failed chunks
- Mechanism to process uncaught exceptions (
mocha
mechanism is unreliable but supported) - Fixtures support similar to pytest fixtures
- Conftest and preloads support
- Test & chunk options
- Multiple reporting system
- Stdout reporter in-box.
- Allure reporter in-box.
- TestRail reporter in-box,
- Easy to provide custom reporter
- May read
CLI
arguments fromJSON
file - May be extended with custom
JavaScript
config - May be used as platform for own testing frameworks development
Reserved functions
- test - testcase definition;
- chunk - part of test executed independently;
- before - hook executed before chunks;
- after - hook executed after chunks;
- beforeChunk - hook executed before each chunk;
- afterChunk - hook executed after each chunk;
- $ - namespace of steps;
- CONF - configuration;
- fixtures - modular & reusable blocks of test;
- iterators - cycles for tests, chunks and other blocks;
- suite - groups tests to suites for visual output mostly;
- scope - groups tests or chunks for visual or logical output, is used inside iterators also;
- session - first root suite, created by framework, not need to reuse by default.
CLI options
Common
--version
- Show version.-h, --help
- Show help.
Arguments
--config [path], -c
- Path to JSON file with CLI arguments. Default is<cwd>/config.json
if it exists.
Note! All options below may be set via json
file (see option --config
above).
Log
--stdout-log
- Print log messages to stdout.--log [path]
- Path to log file. Default is<cwd>/glace.log
.--log-level [level]
- Log level. Supported values areerror
,warn
,info
,verbose
,debug
,silly
. Default isdebug
.
Core
--user-config [path]
- Path to JS file with configuration which will be merged with override default configuration. Default is<cwd>/config.js
if it exists.--session-name [name]
- Tests run session name. Default value includes wordsession
and datetime.--grep <pattern>, -g
- Filter tests by part of name (powered bymocha
).--include <sequence>
- 1) Sequence of test name parts separated by|
in order to choose tests for run, case-insensitive. For example,--include "my first test | my second test"
includes these ones in run only. 2) Path to json file with test names or test ids in order to choose them for run. For example, it can be path to file with failed tests, which is generatedglace-core
if some tests were failed.--exclude <sequence>
- 1) Sequence of test name parts separated by|
in order to exclude tests from run, case-insensitive. For example,--exclude "my first test | my second test"
excludes these ones from run. 2) Path to json file with test names or test ids in order to exclude them from run.--precise-match
- Precise tests inclusion or exclusion matching (check full test name equivalence, not substring matching).--report [path]
- Path to report folder. Default is<cwd>/report
.--dont-clear-report
- Don't clear folder of previous report before tests run.--dont-check-names
- Don't check test names uniqueness (usually useful in unit testing). By default test names should be human-readable and unique among other tests in run.--failed-tests-path [path]
- Path to save failed tests in json format. Default is<cwd>/report/failed-tests.json
. If there are failed tests in run,glace-core
puts its info to json file, which can be used then with--include
option to rerun failed tests only.--root-conftest <path>
- Path to rootconftest.js
which will be loaded before tests but after preloads.--languages <sequence>
- List of tested languages separated with comma. For example,--languages "ru, en, ee"
.--retry [times]
- Number of times to retry failed test. Default is0
.--chunk-retry [times]
- Number of times to retry failed chunk (powered bymocha
). Default is0
.--chunk-timeout [sec]
- Time to execute chunk or hook, sec. Default is180
.--uncaught [type]
- Strategy to process uncaught exceptions. Default value islog
. Supported values arelog
just to log uncaught exceptions,fail
to fail test if uncaught exception happened,mocha
to use defaultmocha
mechanism (unreliable).--kill-procs <sequence>
- List of process names separated with comma, which will be killed before tests run, case-sensitive. For example,--kill-procs "java, chrome, selenium"
.--debug-on-fail
- Enter to interactive debug mode on step failure. Incompatible with--slaves
option.--exit-on-fail
- Finish tests run on first failure.--dots
- Print dots instead of test & chunk names.--errors-now
- Print error message immediately when it happened.--deep-errors
- Print deep objects structure in error message.--interactive, -i
- Launch interactive mode to execute steps manually in terminal. Incompatible with--slaves
option.--slaves <number|auto>
- Split tests by slaves and execute them concurrently in separated processes. If it isauto
, slaves amount will be equal to processor cores amount.
Plugins
--list-plugins
- List found plugins and exit.--plugins-dir [path]
- Path to custom plugins folder.--disable-default-plugins
- Disable default (autodiscovered) plugins.
xUnit
--xunit
- Activate xUnit reporter.--xunit-path [path]
- Path to xUnit report. Default is<cwd>/report/xunit.xml
.--xunit-suite-name [name]
- Tests suite name in xUnit report. By default it's the same as session name.
Allure
--allure
- Activate Allure reporter.--allure-dir [path]
- Path to allure reports folder. Default is<cwd>/report/allure
.
TestRail
--testrail
- Activate TestRail reporter.--testrail-host <host>
- TestRail host.--testrail-user <user>
- TestRail username or email.--testrail-token <token>
- TestRail token.--testrail-project-id <id>
- TestRail project id.--testrail-suite-id <id>
- TestRail suite id.--testrail-run-name <name>
- TestRail run name.--testrail-run-desc <description>
- TestRail run description.
Tools
--testrail-check
- Check TestRail cases consistency with implemented tests.--list-steps [filter]
- List available steps and exit. Iffilter
is omitted, list all steps.--list-tests [filter]
- List collected tests and exit. Iffilter
is omitted, list all tests.--list-fixtures [filter]
- List available fixtures and exit. Iffilter
is omitted, list all fixtures.
Examples
There are e2e tests in order to explore glace-core
examples.
Quality
glace-core
is highly reliable framework. And it's ready to provide confirmation:
- release tests report
- release code coverage