Replies: 3 comments 9 replies
-
Proposed guidelines
#[cfg(test)]
mod tests {
// Place tests here
}
// file: ./src/my_struct.rs
struct MyStruct;
impl MyStruct {
fn some_method() { .. }
}
#[cfg(test)]
mod tests {
#[test]
fn test_of_some_method() { .. }
}
// file: ./tests/my_integration_test.rs
#[cfg(test)]
mod tests {
#[test]
fn integration_test_one() { .. }
#[test]
fn integration_test_two() { .. }
}
I think the right place to put this would be in the CONTRIBUTING.md |
Beta Was this translation helpful? Give feedback.
-
Some quick answers to your questions :) Excellent work though, once we've reached a bit of consensus can you open up a PR to our CONTRIBUTING.md to document this in a stable fashion?
Yep, this is the motivation for that convention. However, modules can be multiple files! The easiest / clearest way to do this is to create a file folder, e.g. This
So, this is mostly a matter of style. For this code base, I think that I'd like to say "in a Doc tests are just bonus, but should probably be preferred for really simple stuff.
Same place as the other unit tests; whether or not something is public isn't important enough to draw this distinction IMO.
I'd say "one clear purpose and concept". Some projects are stricter, and want "one assert per test", but I tend to find that leads to a lot of boilerplate as you set stuff up repeatedly. The main goal here is if our test suite is failing, we should be able to look to the failing unit tests and be able to rapidly pinpoint what we broke. In the case of taffy in particular, this means that we're going to want a unit test for pretty much every statement made in the specs that we're following, since the logic is so |
Beta Was this translation helpful? Give feedback.
-
Nice, this seems like a good direction!
|
Beta Was this translation helpful? Give feedback.
-
Objective
I'm proposing we flesh out and decide on some overall guidelines for writing tests, and where to place them, mostly just to ensure we produce the same kind of output and maintain readability though the project.
Context
Questions
./tests/
folder"Beta Was this translation helpful? Give feedback.
All reactions