Naming test classes.
Normally, you would name your test class like this.
public Product {
//some awesome code here!
}
public ProductTest{
//some awesome test code here!
}
There’s two reasons why I would do this. First, to let IntelliJ find the test class easily and it’s easy to spot the test class when you scroll through.
However, lately inspired by @JeroenSoeters my colleague which I don’t know where he got this from. I started naming test class like this.
public Product {
//some awesome code here!
}
public When_building_a_product {
//some awesome test code here!
}
public When_building_a_product_with_some_more_data {
//some awesome test code here!
}
There’s one reason to do this I can think of. You can clearly see the purpose of this class and you can have multiple test classes or Product instead of having all the tests in one class and everything is cluttered so you have to scroll up and down
Not everybody likes this convention. I hate it at first but I’m starting to use it more often and I like it. What do you guys think?
Til next time,
noppanit
at 00:00