-
Notifications
You must be signed in to change notification settings - Fork 268
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Unit Testing article #1203
Add Unit Testing article #1203
Conversation
source/docs/software/wpilib-tools/robot-simulation/unit-testing.rst
Outdated
Show resolved
Hide resolved
source/docs/software/wpilib-tools/robot-simulation/unit-testing.rst
Outdated
Show resolved
Hide resolved
source/docs/software/wpilib-tools/robot-simulation/unit-testing.rst
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Additionally, can you copy and paste this class and verify that all the code runs as expected? I found a if/else syntax error and could miss other things.
source/docs/software/wpilib-tools/robot-simulation/unit-testing.rst
Outdated
Show resolved
Hide resolved
source/docs/software/wpilib-tools/robot-simulation/unit-testing.rst
Outdated
Show resolved
Hide resolved
source/docs/software/wpilib-tools/robot-simulation/unit-testing.rst
Outdated
Show resolved
Hide resolved
source/docs/software/wpilib-tools/robot-simulation/unit-testing.rst
Outdated
Show resolved
Hide resolved
source/docs/software/wpilib-tools/robot-simulation/unit-testing.rst
Outdated
Show resolved
Hide resolved
source/docs/software/wpilib-tools/robot-simulation/unit-testing.rst
Outdated
Show resolved
Hide resolved
source/docs/software/wpilib-tools/robot-simulation/unit-testing.rst
Outdated
Show resolved
Hide resolved
source/docs/software/wpilib-tools/robot-simulation/unit-testing.rst
Outdated
Show resolved
Hide resolved
source/docs/software/wpilib-tools/robot-simulation/unit-testing.rst
Outdated
Show resolved
Hide resolved
source/docs/software/wpilib-tools/robot-simulation/unit-testing.rst
Outdated
Show resolved
Hide resolved
source/docs/software/wpilib-tools/robot-simulation/unit-testing.rst
Outdated
Show resolved
Hide resolved
source/docs/software/wpilib-tools/robot-simulation/unit-testing.rst
Outdated
Show resolved
Hide resolved
I think this sentence sounds awkward: "There are many unit testing frameworks for most languages". "Unit testing is very common and most languages have multiple frameworks" or similar would be my suggestion. I think it is important to mention under "Writing Testable Code" that they can't define their hardware inline if they want to use unit tests. E.g. I think it would be also good to mention / show how a project needs to use methods to break apart their code so that individual sections can be tested. I am just trying to keep the "I am doing everything in "main" user in mind." What do you think about mentioning Mockito? I (and I know others) have been using it (admittedly not as much as I would like) and I think it makes things significantly easier. |
I agree about the splitting into methods part, though I'm not sure how critical it is an FRC context as each subsystem action is pretty obviously a separate method. What do you mean about inline hardware definitions? I'm not sure how Mockito comes into play here, but I've never used it. |
source/docs/software/wpilib-tools/robot-simulation/unit-testing.rst
Outdated
Show resolved
Hide resolved
So I guess what I am saying is that your code looks great but for teams that aren't set up with subsystems (lowercase) providing and example might help. I will make a quick example. Many teams do:
To use unit testing it will need to be:
Mockito allows you to |
Template robot projects don't have Mockito, that's already a big reason against documenting its usage in an FRC context. If it doesn't have a C++ equivalent, then it definitely won't be documented/suggested. Regarding your example, there are classes to simulate joystick input (see |
given wpilibsuite/GradleRIO#497, it would seem that Gradle never runs tests on deploy. The VS Code option might though. I don't have access to a robot, can someone check this? |
I think there should be a warning about the lack of support from 3rd party vendors about .close and any other things lacking implementation. I had a lot of trouble with |
@Daltz333 is there anything else you'd like me to add, or can this be reviewed/merged? |
Co-authored-by: Dalton Smith <[email protected]>
Split from #1077
I'll add some cleanup input I got from @ThadHouse, and I'd like help with the C++ parts.