Created
September 14, 2018 10:02
-
-
Save wicksome/3e1a97e2b16a2abfae68b6202937f3e6 to your computer and use it in GitHub Desktop.
Simple Test Case Code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const TEST = {}; | |
function assertEquals(expected, actual) { | |
if (expected !== actual) | |
throw new Error( | |
`Not equals.\nExpected :${expected}[39m\nActual :${actual}` | |
); | |
} | |
function RunAllTest() { | |
Object.getOwnPropertyNames(TEST) | |
.filter(name => typeof TEST[name] === "function") | |
.filter(name => name !== "TestCaseExample") | |
.forEach(testCase => { | |
console.log(`## TEST: ${testCase}`); | |
TEST[testCase].call(); | |
console.log(); | |
}); | |
} | |
////////////////////////////////////////////////////////////////// | |
// TEST CODES | |
TEST.test1 = () => { | |
// given | |
// when | |
// then | |
assertEquals("1", "1") | |
}; | |
RunAllTest(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment