-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for a @venus-execute annotation #297
Comments
I think it's a great idea. Would you expect the script to run before each time the test runs (on reload of the test harness page, for example), or only when the test file or code under test changes? |
For simplicity, probably run it every time this test file runs; since you don't know what the JS code will do, it's hard to say what dependencies it has that may change its output. If you wanted to get fancier in the long term, most test frameworks support notions like before, after, before-suite, after-suite, etc. In theory, you could have |
What if we simply enforce an interface for the files included by @venus-execute? Imagine something like:
setup.js: module.exports.before = function () {
// runs before all tests
};
module.exports.beforeEach = function () {
// runs before each test
};
module.exports.afterEach = function () {
// runs after each test
};
module.exports.after = function () {
// runs after all tests
}; |
I like it. Having such an API also gives room to pass some important parameters to the code: module.exports.before = function (testFilePath) {
// runs before all tests
};
module.exports.beforeEach = function (testFilePath, testName) {
// runs before each test
}; |
Sounds good. I'll start on this today. |
Got the before hook implemented. It's available on npm, version 2.3.0. |
Sweet, thanks! |
When writing unit tests with venus, I've frequently needed to do some "setup" work before the test runs. Examples:
@venus-resource
.Many of these are easy to do in server-side unit tests (e.g. JUnit), but they become tricky with the in-browser testing of Venus. My workaround so far has been to do these tasks in my build system (e.g. gradle or sbt), but this doesn't work with venus' hot reload and it makes the test harder to maintain and understand, since it's not clear that critical pieces live in some external build file.
What do you guys think about adding support for a
@venus-execute
annotation? You'd pass it the path of a JavaScript file and it would simply run it in node.js.The script could do any sort of setup you wanted. It would be much more flexible then adding more and more annotations for each custom use case. It makes the test code fairly standalone, more maintainable, and more readable.
Thoughts?
The text was updated successfully, but these errors were encountered: