我是 Jasmine 测试的新手,我需要测试 Nodejs Express 应用程序。我没有找到任何有关在所有测试之前调用的茉莉花助手的文档。
只是尝试我发现添加
beforeAll(async()=>{
...
});
afterAll(async()=>{
...
});
Run Code Online (Sandbox Code Playgroud)
在我的 /spec/helpers/myhelper.js 中,这些函数在所有代码之后和之前执行,但我没有在帮助程序中找到有关此行为的文档。这是标准行为吗?
是否可以在 myhelper.js 中创建我的辅助函数并在测试期间调用该函数?如何?
我的实际 /spec/helpers/myhelper.js 是:
let server = require("../../app");
console.log('server started before tests....');
function testMethod(){
console.log("test helper called");
}
Run Code Online (Sandbox Code Playgroud)
如何从我的测试中调用我的测试辅助方法?
我使用的是茉莉花版本3.2.1
This function need to check that a=b=c=0 or only one is <>0
there is a best way to do this check?
void (int p, int a, int s) {
if ((p != 0 && a != 0)
|| (p != 0 && s != 0)
|| (a != 0 && s != 0)
|| (a != 0 && s != 0 && p != 0)) throw new Exception("Error please set A or P or S");
}
Run Code Online (Sandbox Code Playgroud)