Skip to content

Commit

Permalink
Merge pull request #22 from testdeck/gh-18
Browse files Browse the repository at this point in the history
feature #18: guide/parametrised tests section
  • Loading branch information
silkentrance authored Apr 7, 2019
2 parents 6d365de + 9cd1e4c commit f8511a6
Showing 1 changed file with 170 additions and 0 deletions.
170 changes: 170 additions & 0 deletions pages/guide/parametrised_tests.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
---
layout: guide
section: guide
role: page
order: 70
toc: true
title: Parametrised Tests
label: Parametrised Tests
description: |
Parametrised Tests
---

{:.toc}
## Parametrised Tests

{% highlight TypeScript linenos %}
import { suite, params } from '@testdeck/mocha';

@suite
class Suite {

@params({ arg1: 'foo', arg2: 'bar' })
@params({ arg1: 'bar', arg2: 'foo' }, 'custom test name')
test({ arg1, arg2 }) {
}
}
{% endhighlight %}

### Run Tests

{% highlight shell %}
npm test

...

Suite
test
✓ test 0
✓ custom test name

...
{% endhighlight %}


{:.toc}
## Parametrised Test Naming {% include support-all.html %}

{% highlight TypeScript linenos %}
import { suite, params } from '@testdeck/mocha';

@suite
class Suite {

@params({ arg1: 'foo', arg2: 'bar' }, 'a custom test name')
@params({ arg1: 'bar', arg2: 'foo' })
@params.naming(({ arg1, arg2 }) => `test foobar against ${arg1} and ${arg2}`)
test({ arg1, arg2 }) {
}
}
{% endhighlight %}

### Run Tests

{% highlight shell %}
npm test

...

Suite
test
✓ a custom test name
✓ test foobar against bar and foo

...
{% endhighlight %}


{:.toc}
## Pending Parameter Sets {% include support-all.html %}

{% highlight TypeScript linenos %}
import { suite, params } from '@testdeck/mocha';

@suite
class Suite {

@params({ arg1: 'foo', arg2: 'bar' })
@params.pending({ arg1: 'bar', arg2: 'foo' }, 'SUT does not yet support this')
"test foobar against parameters"({ arg1, arg2 }) {
}
}
{% endhighlight %}

### Run Tests

{% highlight shell %}
npm test

...

Suite
test foobar against parameters
✓ test foobar against parameters 0
- SUT does not yet support this

...
{% endhighlight %}


{:.toc}
## Skipping Parameter Sets {% include support-all.html %}

{% highlight TypeScript linenos %}
import { suite, params } from '@testdeck/mocha';

@suite
class Suite {

@params({ arg1: 'foo', arg2: 'bar' })
@params.skip({ arg1: 'bar', arg2: 'foo' }, 'test fails on this, no time fixing')
test({ arg1, arg2 }) {
}
}
{% endhighlight %}

### Run Tests

{% highlight shell %}
npm test

...

Suite
test
✓ test 0
- test fails on this, no time fixing

...
{% endhighlight %}


{:.toc}
## Focused Parameter Set Testing {% include support-all.html %}

{% highlight TypeScript linenos %}
import { suite, params } from '@testdeck/mocha';

@suite
class Suite {

@params({ arg1: 'foo', arg2: 'bar' })
@params.only({ arg1: 'bar', arg2: 'foo' }, 'should be fixed now...')
test({ arg1, arg2 }) {
}
}
{% endhighlight %}

### Run Tests

{% highlight shell %}
npm test

...

Suite
test
✓ should be fixed now...

...
{% endhighlight %}

0 comments on commit f8511a6

Please sign in to comment.