-
Notifications
You must be signed in to change notification settings - Fork 41
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
Unit testing #12
Comments
I don't know if you already learned about this on your own but here's my $0.05: Unit testing as I understand it is part of a development philosophy called Test-Driven Development (TDD). In TDD, you write a test for a feature that you plan to implement FIRST before you write the feature itself. The test fails (because the feature is not there yet). Then you write the minimal amount of code to make the test pass. You keep writing tests and writing code, making sure all previous tests keep passing. For example, a feature request currently exists on the site called "allow image upload from URL."
I want to learn more about the Laravel framework and contribute, but there's never enough time. :( |
That's a really good synopsis, thank-you for taking the time to write it out. I've been putting this off since day one, but I'm writing out a feature for administrative config now. I'll see if I can add some unit tests for that. I think Laravel has a built-in way of doing unit tests, so this is a good excuse to try it out. |
Unit testing is difficult to get into, but is very rewarding! If you're interested in a book on unit testing, I can recommend "Extreme Programming" by Kent Beck. That book was what inspired me to really commit and start writing the tests for everything. |
I did Test Driven Development recently, for my Software Engineering class, and I definitely recommend it. Adding to what @panasenco said, TDD was very rewarding when we needed to refactor code. Changing lots of code can be scary, but not so much when you have lots of tests to help you debugging and understanding whether the new code is working 100% or not 😄 It also helps you understand the quality of your program based, as you can simply check the percentage of tests that pass and fail. However, that implies the tests are good and thorough. They can be seen as requisites of your program - if you want your program to do X, test the X functionality and make sure it passes. |
@panasenco If you'd like to look at commits 21a3333 and b413875, this is my attempt at doing unit tests. I'd like input before going out into other unit tests.
|
@jaw-sh These look great to me! I like that you wanted to make sure the response codes were correct before doing anything else. The next step would be to add extra tests that test functionality (is this element on the page that the user is navigated to?). Awesome start IMO! |
@panasenco That's a good idea. Interestingly, this already helped me resolve a bug. Board logs had become broken with recent changes because they referenced a template which requires data the controller doesn't supply. When I saw a 500 error for that assertion it made me laugh. This whole thing is brilliant. At my old job, which had hundreds of views and zero unit tests, it was a continuous game of whack-a-mole because new features would break old ones and we'd not notice until a client complained. |
Haha it's great to see another convert. :D |
I don't know what Unit Tests are but they sound really great.
Be sure to write #1 Proper Documentation on them, too.
Laravel Doc: http://laravel.com/docs/5.0/testing
The text was updated successfully, but these errors were encountered: