Comments (7)
Hi,
thank you to report it. Could you please post/link an example?
from rstest.
Maybe I don't understand your testcase... in la10736/rstest_issue2 seams to work as expected.... I missed something?
from rstest.
I do not have a trimmed down version to act as a test case – at least not yet, but I can try. The actual problem I have observed is with the tests for me-tv-schedule in the Me TV repository. https://github.com/Me-TV/Me-TV/blob/master/src/bin/me-tv-schedule.rs the #[rstest_parametrize] code compiles (if there is an error, it gets flagged so definitely being compiled) but is not actually run. The #[test] entries above are executed as normal.
I pulled the rs8080 project and ran it's tests and they work fine for me, but they are in src/ not src/bin/. The test cases you mention are all spawning a process to run the tests (I believe) and so are a somewhat different thing to what I have.
I have no idea what might be wrong, which is why it is so vexing.
from rstest.
Hi, maybe I got it. You cannot write arbitrary rust code in code annotation. To work around this limitation I used Unwrap("<some rust code>")
syntax. So, try to change your code into:
#[rstest_parametrize(
datum, expected,
case("2018-12-29T18:15:33", Unwrap("NaiveDate::from_ymd(2018, 12, 29).and_hms(18, 15, 33)")),
case("2018-12-29 18:15:33", Unwrap("NaiveDate::from_ymd(2018, 12, 29).and_hms(18, 15, 33)"))
)]
fn parse_datetime_string(datum: &str, expected: NaiveDateTime) {
match parse_to_datetime(datum) {
Ok(result) => assert_eq!(result, expected),
Err(e) => assert!(false,"failed to parse: {}", e),
};
}
As value in your test case you can use just direct value as numbers, bools and strings or if you need to write some rust statements use Unwrap("<code>")
construct.
I know that Unwrap
is not a good name but I didn't found any better one. Maybe I'll use a shorter one in the next version like r("<code>")
.
from rstest.
Aha, that was it. Works now. :-)
It is a shame having to put code as string since it is easy to put syntax errors in that are not checked by IDEs and compiler until test execution time. However, having parameterised tests is a huge saving in lack of boilerplate.
I did contemplate trying the "use a macro" technique of handling the boilerplate, but I really like pytest.mark.parametrize
so went with rstest instead! I will be using this a lot, thanks for making it.
from rstest.
Next release will report errors like this and checks the Unwrap
strings at compile time with readable errors.
For IDE highlight I hope to have some time to look in intellJ language injection to have it at least in IntelJ.
from rstest.
Having syntax checks early will be very helpful.
I use CLion for Rust (because of gdb support) rather than IntelliJ IDEA, but I think there is no difference for plugins. I guess contacting the Rust plugin team at JetBrains is a good first step?
from rstest.
Related Issues (20)
- skip cases based on feature flag? HOT 5
- `#[once]` fixtures are unsound for types that are not `Sync` HOT 4
- clippy::duplicated_attributes warning with rust 1.79.0-nightly HOT 3
- By-reference fixtures HOT 12
- Update `rstest_reuse` docs and release new version
- `#[from(source)]` should accept path also and not just idents
- rstest_reuse: "the `async` keyword is missing from the function declaration" HOT 1
- replace return <expr>; with <expr> [needless_return] HOT 3
- Support dynamic `#[values]` HOT 1
- Feature: Optional label in the `#[case...]` HOT 1
- Dynamically set #[values(..)] HOT 1
- New test files are only recognized after `cargo clean` HOT 4
- feat: provide a cargo feature to disable the proc macro inference in #221 HOT 2
- consider adding a `wasm-bindgen` feature HOT 2
- Recommendation on choosing between different sets of `#[values(...)]`?
- Mixing `#[rstest]` and `#[serial]` breaks VS Code's IntelliSense with rust-analyzer HOT 3
- Possibility of resolving a fixture only once per test?
- Automatically test all variants of an enum HOT 1
- unused warning for case variables used by fixture #[with(var)] HOT 1
- Can #[files] use relative paths HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rstest.