[General boards] [Winter 2019 courses] [Fall 2018 courses] [Summer 2018 courses] [Older or newer terms]

Fishtank methods in tests


Am I allowed to use Fishtank methods in my tests? Or mock the Fishtank class?


You can’t mock static methods (unfortunately…) – you should just make sure to reset the fishtank in your @Before method if you need to test things that involve it (e.g., bubble spawning)


The worst case is that “state leaks” across tests, that is, one test spawns a bubble in the fish tank that then affects another test – this is really bad and makes things hard to understand, so make sure to reset if you ever do this in your future coding endeavours.