1.1.1 • Published 5 years ago

@outwalk/tryout v1.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
5 years ago

Tryout

Tryout is a minimalistic object oriented unit testing framework for JavaScript.

Actions License Chat Server


Installation

Install using npm:

npm install --save-dev @outwalk/tryout

Install using yarn:

yarn add --dev @outwalk/tryout

You can learn the JavaScript API by reading the documentation.

Tryout is available in CommonJS and ES Module formats.


Tryout TestCase

You create your tests by creating a class and extending TestCase. By extending TestCase the TestRunner can detect all the functions the class has and will run all of them automatically.

Example:

import { TestCase }  from "@outwalk/tryout";

/* create a test case */
class TestSomething extends TestCase {

    /* test something specific */
    testSomethingFunction(){

    }
}

Tryout TestRunner

To run your tests you pass an array of test cases or test groups to the TestRunner.run function.

Example:

import { TestCase, TestRunner }  from "@outwalk/tryout";

/* create a test case */
class TestSomething extends TestCase {

    /* test something specific */
    testSomethingFunction(){

    }
}

/* run your test cases */
TestRunner.run([
    new TestSomething()
]);

Tryout TestGroup

A TestGroup can be used to make your test output cleaner and more organized. TestGroup can be given a name and all tests belonging to the group will be run under that name.

Example:

import { TestCase, TestGroup, TestRunner }  from "@outwalk/tryout";

/* create a test case */
class TestSomething extends TestCase {

    /* test something specific */
    testSomethingFunction(){

    }
}

TestRunner.run([
    new TestGroup("SomethingGroup", [ 
        new TestSomething()
    ])
]);

Tryout Assertion

You can test your code using TestCase assertion functions.

Example:

import { TestCase }  from "@outwalk/tryout";

/* create a test case */
class TestSomething extends TestCase {

    /* test if something is true */
    testTrue(){
        super.assertTrue(true, "Should verify that condition returns true");
    }

    /* test if something is false */
    testFalse(){
        super.assertFalse(false, "Should verify that condition returns false");
    }

    /* test if something is equal */
    testEqual(){
        super.assertEqual(1, 1, "Should verify that variables are equal");
    }

    /* test if something is not equal */
    testNotEqual(){
        super.assertNotEqual(1, 2, "Should verify that variables are not equal");
    }

    /* test a condition */
    testCondition(){
        super.assert((1 < 2), "Should verify that a condition returns true");
    }
}

Why?

Tryout was developed to make testing easy using a minimal object oriented design with no dependencies. This lets you focus on testing your code instead of learning a large framework.


Support

Having trouble with Tryout? Create a new Issue or contact us on our website.


License

Tryout is licensed under the terms of the MIT license.

1.1.1

5 years ago

1.1.0

5 years ago

1.0.1

5 years ago

1.0.0

6 years ago

0.1.0

6 years ago