When testing, conditionally add Serialize/Deserialize to struct

I have input structures and output structures.
I use serde::Deserialize on the input structure and serde::Serialize on the output structures. (easy)
In testing I want to also Serialize the input structures to be able to pass in data and Deserialize output structures to validate.
#[derive(Serialize, Deserialize, Debug)] works but when not testing adds and extra impl.

*** Is there a way to conditionally add Serialize/Deserialize when testing?

I have tried
#[cfg_attr(feature = "test", Deserialize)] NOT Work
#cfg(test, Deserialize)] NOT Work

#[cfg_attr(test, derive(Deserialize))]

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.