23 testplan - ranhs/soda-test GitHub Wiki

soda-test allows you getting your tests as a json file. This file represent the test-plan.
To allow creation of test-plan add the following script to your package.json file:

"soda-plan": "node node_modules/soda-test/plan \"dist/test-samples/**/*.test.js\" testPlan.json"

in this example it looks for all *.test.js files under to the dist/test-sample
change this reg expression to match your project test files the last argument is the name of the test-plan output file (testPlan.json). You man use a different file. It is recommended to add this file to the .gitignore file, so it will not not be committed. If this argument is not specified, the JSON of the test-plan is written to the console.

Creating the Test-Plan

To create the test plan execute from the the command line:

npm soda-plan

As a result the output json file shall be created, or the output shall be written to console.

Extra Data

In many cases the names of the it/context/case/describe is not enough for the test plan. You may add an extra data on each one of them. The extra data is an object with as many properties as you like, that their value can be strings or numbers. Avoid reserved properties names: text, type, children, pending. It is recommended to use the same properties for all extra-data. In the follwoing exsamples we shall add description property to describe what the it/context/case/describe is doing
To add extra data to an it method, add a second argument to the it decorator

    @it('Not enough arguments', {description: "error message when only 2 arguments"})
    invalidArguments() {
    }

To add extra data to a context, add a second argument to the context decorator
@context('Creating a Test Plan', {description: 'we tests here the creation fo test-plan'})

To add extra data to a describe class, add a second argument to the describe decorator
@describe('TestPlan1', {description: 'Test the ability to create a test plan'})
class PlanTest {
}

To add extra data to a test-case, add a third argument to the testCase decorator. If you don't have a second argument, put null in it
    @testCase('dummy test case', StepClass, null, {description: 'The Dummy Test Case'})
    dummyTestCase(step: stepMethod<StepClass>) {
    }

To Add extra data to a test-step, add a third argument to the step method, If you don't have a second argument, put null in it

        step("Step1",null,{description: 'this is step # 1'}).Dummy()

Note that the extra data does not effect the execution of the test, but add information to the test-plan

Comments

You may add comments before and between test-steps / it, to explain why we are doing this, or why we are getting this results, to any other reason to make the test-plan more clear.
note that a comment as a text, and may also have extra data.

To add comment before it method (inside or outside of a context), you need to add a comment decorator before the it decorator. You may add several comment decorators for a single it decorator. the comment decorator gets a single text argument and optionally an extra data object argument

@context('Creating a Test Plan')

@comment('Validating the JSON of the test plan')
@comment('in console or in a file', {description: 'more information...')

    @it('test plan in console')
    createTestPlan1() {
    }

To add a comment before a test-step call (inside a test-case), you need to add a call to a comment method that defined on the step method. The step.comment except a single text argument and optionally another extra-data object argument.
        step.comment('another dummy comment')
        step.comment('dummy comment with description', {description: 'the dummy comment description'})
        step("Step2",null,{id: 2}).Dummy()

⚠️ **GitHub.com Fallback** ⚠️