Skip to content

NemerleUnit

Alex Zimin edited this page Aug 19, 2011 · 4 revisions

NemerleUnit is a domain specific language for writing NUnit tests. Tests are transformed to NUnit equivalent on compilation. Use NUnit runner to run them.

NemerleUnit does not work with version 0.9.3 of Nemerle. You need nemerle compiler from at least 7071th revision. That means you need to build yourself a compiler from the sources.

Table of Contents

Example

#pragma indent
using NemerleUnit

setup
    def abc = ["a","b","c"]

teardown
    () // you could dispose here

test "length of an empty list"
    assert [].Length equals 0 

test "length of a three element list"
    assert abc.Length equals 3

test "equals"
    assert abc equals ["a","b","c"] 
    assert abc does not equal ["c","b","a"] 

test "contains"
    assert abc.Contains("a") 
    assert abc.Contains("b")
    assert abc.Contains("c")

https://github.com/rsdn/nemerle/tree/master/tools/nemerle-unit/src/tests/assertions.n

Use

To compile tests you need to link both NUnit.Framework.dll and NemerleUnit.dll (in -ref param).

   ncc -r NUnit.Framework.dll -r NemerleUnit.dll -t library -o tests.dll example.n

After compilation you can run them with any NUnit compatible runner.

Image:Nunit-runner.png Yes, spaces in method names! :)

Once I have had some nasty problems with compiling tests because I had Nemerle.dll in the local folder; be aware.

Macros

The implementation is done using macros. To compile them you need NUnit.Framework.dll, NUnit.core.dll and Nemerle.Compiler.dll.

https://github.com/rsdn/nemerle/tree/master/tools/nemerle-unit/src/macros/macros.n

Sources are kept in nemerle svn repository under https://github.com/rsdn/nemerle/tree/master/tools/nemerle-unit

Contact

The author of NemerleUnit is nemerle-wiki.20.luntain@spamgourmet.com. Any feedback is welcome.

Clone this wiki locally