Closed michaelsilver closed 8 years ago
Hey Michael, I agree wholeheartedly with using JUnit and I'm sure Dave would be thrilled. I think that we need to really consider removing Vector2D from the drive code especially given that a goal of the off season is to make the drive train code really good. It doesn't make sense to replicate low level functionality that has been integrated into java and although writing our own class was really cool, I'm worried about us realizing there is an edge case that misbehaves like we found before and it totally screwing up the drive code. Just my 2 cents
Many thanks, Owen G.
On Mon, Oct 5, 2015 at 10:08 PM, Michael Silver notifications@github.com wrote:
Unlike most things in FRC, Vector2D is easily unit-testable. JUnit http://junit.org/ is the standard unit testing suite for Java that is usually used in conjunction with Maven by setting JUnit as a dependency https://github.com/junit-team/junit/wiki/Download-and-Install. This ChiefDelphi discussion http://www.chiefdelphi.com/forums/showthread.php?t=118275 suggests that it is better to manually add dependencies rather than deal with Maven. @PaulTerrasi https://github.com/PaulTerrasi, what are your thoughts?
— Reply to this email directly or view it on GitHub https://github.com/246overclocked/scorpion/issues/1.
Sure, I'm open to that. The problem we had earlier was that the vector libraries built into Java seemed too complicated to deal with. If you've figured out any of the details, I'd be excited to learn more!
I think that might have been because the java "vector" class is actually just a modified arraylist. There are a bunch of premade vector classes in popular math and science libraries to choose from that should be plug and play. It's just a thought, we can see what makes sense
Many thanks, Owen G.
On Mon, Oct 5, 2015 at 10:36 PM, Michael Silver notifications@github.com wrote:
Sure, I'm open to that. The problem we had earlier was that the vector libraries built into Java seemed too complicated to deal with. If you've figured out any of the details, I'd be excited to learn more!
— Reply to this email directly or view it on GitHub https://github.com/246overclocked/scorpion/issues/1#issuecomment-145727246 .
Ok, I opened #2 so we can discuss the specific libraries you have in mind. I'll leave this issue open so we can discuss JUnit. If we decide to go the #2 rout, I'll close this issue because we don't need to unit test a standard library, but knowing about JUnit in general would be useful.
So JUNit is going to take a pretty big effort if we want to use it. Besides having to write the tests, we will basically need to rethink how we structure our code. The key to making JUnit work is avoiding having any dependencies on the WPILib in the methods that we test. In addition, we either need to make these methods static, or put them inside classes which do not depend on the WPILib. I think this is doable as long as people keep these things in mind when they are writing the code. Also, not being able to use the WPILib obviously means that we are limited in what we can test. But I think the big, math heavy code like Vector2D and forwards/reverse kinematics could really benefit from JUnit.
On Mon, Oct 5, 2015 at 11:05 PM, Michael Silver notifications@github.com wrote:
Ok, I opened #2 https://github.com/246overclocked/scorpion/issues/2 so we can discuss the specific libraries you have in mind. I'll leave this issue open so we can discuss JUnit. If we decide to go the #2 https://github.com/246overclocked/scorpion/issues/2 rout, I'll close this issue because we don't need to unit test a standard library, but knowing about JUnit in general would be useful.
— Reply to this email directly or view it on GitHub https://github.com/246overclocked/scorpion/issues/1#issuecomment-145729853 .
Yes, well that's all part of writing good code (i.e. testable) :smile: It'll be a major goal this season, and code review via PRs will help.
Any ideas on how specifically to import JUnit as a dependency and set up testing? Through Maven? Manually somehow? I have no experience with JUnit; only equivalent testing software in other languages.
Looking at Maven, it seems to me like it isn't really the best thing for an FRC project. It has a lot of features that I really don't want to need to deal with just to use JUnit for make 6 or 7 tests per project.
Instead, I think it we should just do it manually. This https://github.com/junit-team/junit/wiki/Getting-started seems like a very easy way of doing it. It simply requires that the entire class doesn't have any dependencies on the WPILib, or else the test will encounter an error because it isn't running on a robot. To be honest, putting something like the forward kinematics for the drivetrain in a separate class isn't the best way to structure your code, but it is worth it to make the code testable. That's what I mean when I say this will force us to structure our code differently than we normally would.
On Tue, Oct 6, 2015 at 9:12 PM, Michael Silver notifications@github.com wrote:
Yes, well that's all part of writing good code (i.e. testable) [image: :smile:] It'll be a major goal this season, and code review via PRs will help.
Any ideas on how specifically to import JUnit as a dependency and set up testing? Through Maven? Manually somehow? I have no experience with JUnit; only equivalent testing software in other languages.
— Reply to this email directly or view it on GitHub https://github.com/246overclocked/scorpion/issues/1#issuecomment-146048403 .
Guys, Have you looked at TestNG (http://testng.org/)? I was using it long time ago and liked it better than JUnit but it was before JUnit4. I think it's worth looking at and comparing. Also one of my favorite articles on the subject of Unit testing: http://martinfowler.com/articles/mocksArentStubs.html. Should be a good read especially in the context of isolating dependencies on the WPILib.
-Kostya
Actually, thanks to Eclipse, looks like setting up JUnit should be pretty straightforward: https://courses.cs.washington.edu/courses/cse143/11wi/eclipse-tutorial/junit.shtml
FRC uses the Ant build system, and Eclipse comes with JUnit installed already. According to the tutorial, Eclipse should be able to configure the build path automatically.
Should I move this issue over to dodgeball and try to give it a whorl?
This issue was moved to 246overclocked/dodgeball#13
Unlike most things in FRC, Vector2D is easily unit-testable. JUnit is the standard unit testing suite for Java that is usually used in conjunction with Maven by setting JUnit as a dependency. This ChiefDelphi discussion suggests that it is better to manually add dependencies rather than deal with Maven. @PaulTerrasi, what are your thoughts?