-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
In-language Sway Testing #1375
Comments
I love the idea of being able to write tests for sway in sway. I don't have many thoughts on your implementation suggestions yet, but just wanted to add a couple motivation points that @JoshuaBatty and I were chatting about recently:
|
@mitchmindtree regarding the Forc test point, is there a way to resolve that, i.e. some kind of cargo test scoping we could add to prevent this? I think I've had this problem before and didn't quite understand what was going on. As for the other points, I agree. I think there is a lot of potential. We would need a nice programmatic way of deploying contracts, but that's basically it, the other stuff is quite trivial to implement. |
Also, is that caveat regarding |
I'd like to add another motivational point for implementing this:
|
Here I propose a simple test harness plugin, allowing tests in Sway.
Essentially you have a simple library, which contains a few asserts (assert_eq, assert_neq, etc.). Call it
swest
: Sway+Test.Tests are written in a Sway script using the asserts. A plugin is installed, say
swest
. What doesswest
plugin do? Simple, it runs the script, picks up the logs, and interprets the log data as a test output (similar too many other harnesses).The benefit of this: tests can be written in Sway without knowing any rust or having to configure a Rust test harness.
Example:
CLI:
Output:
Log construction:
assert_eq
would use something likelogd
and put all the data in memory, then would encode the appropriate test values. The test harness itself would do the comparison.Eventually with annotations we could define the test methods better, and also the harness could pick up what section of tests it's running.
For now this is an idea for a conversation only.
Cavettes:
The text was updated successfully, but these errors were encountered: