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 read a lot to find out how we can implement this. It was a good exercise to read through Ruby-Doc, use Stack Overflow and find some helpful tutorials about MiniTest for example.

We had to deal with the fact, that our first ideas didn’t work as expected…

Magda is working hard

Magda is working hard

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…

Firt sight of nano_padawans_test

Firt sight of nano_padawans_test

nano_padawans_test is born. You can take a look at our repo, if you like: nano_padawans_test