Comments (11)
@luke-biel - It's seems that we missed panics
scenario.
@gh0st42 - it should not be a breaking change, its more a oversight in that case, therefore a bug. Sorry for that.
Please see #50 for more context.
For now, you skip this check by enabling feature allow_result
.
from test-case.
Allright, I think this one deserves its own issue. Let me create one and then we should continue figuring out the right approach for it :)
from test-case.
Ah! Good to know about the silent failures!
I initially tried your suggestion to resolve the issue but you run into:
30 | #[test_case("ISBN:1839485743" => Ok(()); "isbn10")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `dyn StdError == dyn StdError` | = help: the trait `PartialEq` is not implemented for `dyn StdError` = note: required because of the requirements on the impl of `PartialEq` for `Box<dyn StdError>`
I just tested locally that
#[test_case("abc" => matches Ok(_))]
fn dyn_err(input: &str) -> Result<(), Box<dyn std::error::Error>> {
Ok(())
}
works. It may be a solution in your case untill we introduce proper handling of Result
.
from test-case.
@gh0st42 - Is your case solved?
yes, version 1.2.3 works again even without the allow_result
feature.
thank you for the quick response.
from test-case.
Mea culpa. I overlooked this. Fix is on it's way, just needs a review.
from test-case.
1.2.3
was just published
from test-case.
I'm still receiving the same error above on 1.2.3
with the following test:
#[test_case("ISBN:1839485743"; "isbn10")]
#[test_case("ISBN:1839485743123"; "isbn13")]
#[tokio::test]
async fn test_bibliography_key_serde(expected: &str) -> Result<(), Box<dyn Error>> {
let key: BibliographyKey = serde_json::from_str(expected)?;
let actual = serde_json::to_string(&key)?;
assert_eq!(expected, actual);
Ok(())
}
from test-case.
@bspradling In that case this is expected behavior.
Your tests were passing silently, so even if there was an Err() the test would pass.
For now, v1.2.2 introduced a compile-time error so you can review this test.
Currently test_case
does not support implicit Result<(), Box<dyn Error>>
handling which was introduced in Edition 2018.
To solve this problem you should use test case syntax to expect value explicitly.
In your case:
#[test_case("ISBN:1839485743" => Ok(()) ; "isbn10")]
#[test_case("ISBN:1839485743123" => Ok(()) ; "isbn13")]
#[tokio::test]
async fn test_bibliography_key_serde(expected: &str) -> Result<(), Box<dyn Error>> {
let key: BibliographyKey = serde_json::from_str(expected)?;
let actual = serde_json::to_string(&key)?;
assert_eq!(expected, actual);
Ok(())
}
This should work.
We know that in long term we need to allow implicit Result<(), dyn Err>
but our priority was to first prevent any silently failing cases. I hope you understand it.
from test-case.
Ah! Good to know about the silent failures!
I initially tried your suggestion to resolve the issue but you run into:
30 | #[test_case("ISBN:1839485743" => Ok(()); "isbn10")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `dyn StdError == dyn StdError`
|
= help: the trait `PartialEq` is not implemented for `dyn StdError`
= note: required because of the requirements on the impl of `PartialEq` for `Box<dyn StdError>`
from test-case.
Actually it might be just a edge-case of #50
from test-case.
@gh0st42 - Is your case solved?
from test-case.
Related Issues (20)
- Silencing compared values HOT 2
- Uppercase and lowercase generated test function collide HOT 4
- Does not fully work with `pretty_assertions`, fix OK? HOT 2
- feature request: test_case generators HOT 1
- Getting current test case description from within the test function HOT 4
- Expose `TestCase` struct publicly for reuse HOT 1
- please include LICENSE file in all published crates HOT 2
- Set test case function `Ident` spans to corresponding `test_case` spans HOT 2
- Is return value in test required? HOT 8
- On nightlies and betas, `cargo +nightly clippy` creates `items_after_test_module` warnings HOT 9
- Type as test case argument HOT 9
- When generating assert the right side should be the "correct" side. HOT 19
- New clippy lint in Rust 1.71.0, `items_after_test_module`, affecting integration tests HOT 3
- upgrade dependency proc-macro2 HOT 1
- error[E0432]: unresolved import `test_case_macros::test_matrix` using 3.2.0 HOT 3
- Test case macro should not rely on implementation details of the built-in test framework HOT 3
- `syn::Result::ok` silently discards errors
- macro for bench cases HOT 1
- Conditional flags for ignore and inconclusive HOT 3
- Iterable args: a way to expand a given argument of `test_matrix`
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 test-case.