All Projects → tshm → elm-doctest

tshm / elm-doctest

Licence: MIT license
doctest runner against Elm-lang source files

Programming Languages

elm
856 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to elm-doctest

Unittest Xml Reporting
unittest-based test runner with Ant/JUnit like XML reporting.
Stars: ✭ 255 (+1861.54%)
Mutual labels:  test-runner, unittest
Testfx
MSTest V2 framework and adapter
Stars: ✭ 391 (+2907.69%)
Mutual labels:  test-runner, unittest
Green
Green is a clean, colorful, fast python test runner.
Stars: ✭ 691 (+5215.38%)
Mutual labels:  test-runner, unittest
Nunit3 Vs Adapter
NUnit 3.0 Visual Studio test adapter for use under VS 2012 or later
Stars: ✭ 158 (+1115.38%)
Mutual labels:  test-runner
Carton
📦 Watcher, bundler, and test runner for your SwiftWasm apps
Stars: ✭ 171 (+1215.38%)
Mutual labels:  test-runner
NarrativeTest.jl
Julia library for functional testing.
Stars: ✭ 18 (+38.46%)
Mutual labels:  doctest
tester-jest
Tester Jest is a tester provider for the Atom Tester.
Stars: ✭ 21 (+61.54%)
Mutual labels:  test-runner
Spectrum
A BDD-style test runner for Java 8. Inspired by Jasmine, RSpec, and Cucumber.
Stars: ✭ 142 (+992.31%)
Mutual labels:  test-runner
cpp14-project-template
A simple, cross-platform, and continuously integrated C++14 project template
Stars: ✭ 64 (+392.31%)
Mutual labels:  doctest
Marathon
Cross-platform test runner written for Android and iOS projects
Stars: ✭ 250 (+1823.08%)
Mutual labels:  test-runner
Htmltestrunner
A Test Runner in python, for Human Readable HTML Reports
Stars: ✭ 228 (+1653.85%)
Mutual labels:  test-runner
Vim Test
Run your tests at the speed of thought
Stars: ✭ 2,287 (+17492.31%)
Mutual labels:  test-runner
doctest
The fastest feature-rich C++11/14/17/20 single-header testing framework
Stars: ✭ 4,434 (+34007.69%)
Mutual labels:  doctest
Nunit Console
NUnit Console runner and test engine
Stars: ✭ 168 (+1192.31%)
Mutual labels:  test-runner
catch-lest-other-comparison
Tabularised feature comparison between Catch, doctest and lest C++ test frameworks
Stars: ✭ 20 (+53.85%)
Mutual labels:  doctest
Karma
Spectacular Test Runner for JavaScript
Stars: ✭ 11,591 (+89061.54%)
Mutual labels:  test-runner
power-doctest
JavaScript Doctest for JavaScript, Markdown and Asciidoc.
Stars: ✭ 45 (+246.15%)
Mutual labels:  doctest
Junit Dataprovider
A TestNG like dataprovider runner for JUnit with many additional features
Stars: ✭ 226 (+1638.46%)
Mutual labels:  test-runner
Specjour
distributed rspec & cucumber via bonjour
Stars: ✭ 214 (+1546.15%)
Mutual labels:  test-runner
blackdoc
run black on documentation code snippets
Stars: ✭ 31 (+138.46%)
Mutual labels:  doctest

Build Status npm version

elm-doctest

doctest runner against Elm-lang source files

installation

npm install elm-doctest

It depends on elm and assumes that elm-make and elm-repl are available either via systemwide installation or npm module installation. Make sure elm-make succeeds with your elm source files.

how does it work?

It utilizes elm-repl for expression evaluation and compare the values against the expected value. (It does not comapre stringified values like haskell doctest does via GHCi outputs.)

It only evaluates the expressions that follows -- >>> (i.e. Elm comment symbol followed by space and three LT chars until end of the line) and the expression on the next line after -- .

For example, if the comment states:

-- >>> x =
-- >>>   1 + 2
--
-- >>> x * 2
-- 6

Then, elm-doctest asks elm-repl to evaluate the actual code section in the source file and effectively following expression:

((1 + 2) * 2) == (6)

If value reported by elm-repl is True then test passes, fail otherwise.

usage

Usage: elm-doctest [--watch] [--help] [--elm-path PATH]
                   [--pretest CMD] FILES...
  run doctest against given Elm files

Available options:
  -h,--help             Show this help text
  --pretest CMD         Command to run before doc-test
  --elm-path PATH       Path to elm executable
  -w,--watch            Watch and run tests when target files get updated

example

ModuleTobeTested.elm:

module ModuleTobeTested exposing(..)

-- |
-- >>> add 3 5
-- 8
--
-- >>> removeZeros [0, 1, 2, 3, 0]
-- [1, 2, 3]
--
-- >>> greetingTo "World"
-- "Konnichiwa World"
--
add : Int -> Int -> Int
add x y = x + y

greetingTo : String -> String
greetingTo x = "Hello " ++ x

removeZeros : List Int -> List Int
removeZeros = List.filter (\x -> x /= 0)

evaluation elm-doctest ModuleTobeTested.elm outputs

Starting elm-doctest ...

 processing: test/TestData/TestFail.elm
### Failure in test/TestData/TestFail.elm:10: expression
  greetingTo "World"
expected: "Konnichiwa World"
 but got: "Hello World"
Examples: 3  Failures: 1

limitation

As it utilizes elm-repl, the script must be runnable inside elm-repl. For example, code which imports elm-lang/[email protected] module cannot be tested. Since the stdout is used to evaluate the test result, avoid using Debug.log.

Also, make sure elm-make runs without error. You can auto run elm-make by using --pretest command-line option.

license

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].