I am trying to test the parsing of a (long) raw string via serde.
The test throws an error without any explanation for me to go on.
See: Rust Playground
The construction works, and the testing works.
Also the long raw string doesn't appear to be an issue, it's when serde gets involved, but there is nothing to go on, nor any switch that I can see that shows more info?
How can I make this working?
The error :
thread 'tests::parse_master_2_11_1_0_build_305' panicked at 'called `Result::unwrap()` on an `Err` value: Error("missing field `type`", line: 557, column: 5)', src/lib.rs:6001:43
type", line: 557, column: 5
You should probably put that JSON in a file and include it, cf
Thank you so much. It took me a while to understand all that I had done wrong.
I think the first thing I've done wrong is that I explicitly quit the parsing if it failed, which meant cargo test could not finish?
The second thing is really silly, I made a paste error in my original code which changed the field name from 'type' to '#type'.
But I think the lesson learned here for me is that when unit testing, you should leave the error handling to the unit test, and do not do things like quitting, because that interferes with the unit test.
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.