Week 2 Day 3 Nano Test by Padawans
Let’s walk on the path of enlightment in becoming a test driven Code_Padawan!
And what could be better to learn something about tests than writing our own small test framework?
The Test superclass has this functionality:
- find all methods that end on „_test“ and run them
- find all classes that inherit from Test
- make assertions and get the result of the method
It’s super helpful, as you don’t want to run every single test method one after another. Test finds all of tests for you (or those that you want to be found) and runs them all at once.
Yes, this sounds like nothing big, but we have learned a lot out of it:
- What it means, that all classes in Ruby are an object
- That there is something called „self“, that gives you access to the current object
- You can search for method names and save them into an array, and run them then by using „send“
We had to deal with the fact, that our first ideas didn’t work as expected…
But at the end of the day we wrote something, that worked. It’s still not finished, we have to do some refactoring, buuuuut it’s a piece of working code. Written by ourselves…
nano_padawans_test is born. You can take a look at our repo, if you like: nano_padawans_test