Closed balvinderimpinge closed 6 years ago
Hi Balvinder - how can we test this behaviour?
@joereddington that's a good question. From a functional point of view it is relatively easy to test, you simply load an example (like Communikate) click on a cell which links to another board and observe that the linked board loads.
From a unit test pov it is not so simple. I would say the code as written is impossible to unit test. The issue is how read_json is architected. We really need to do #76 before we can create unit tests for this functionality.
This is how I unit tested the same behaviour previously (I should probably add a comment to that effect) is there's something I'm missing?
IMHO, what you are doing in the tests you linked to is UI testing. You are testing that when you call the code it has the desired impact on the UI. I don't think you can call it unit testing because in fact you are testing almost the entire system, but only for one cause-effect. True unit testing would require that you can call one isolated unit of code with a known initial state and demonstrate that after the unit has run some new state has been reached. In this specific case, what we want to test is that when you want to load a new board you do in fact load that new board. However the way the code is written is recursive. When you click on a link the code initiates the whole process again from within that method. So as the code is currently structured it's not really possible to isolate testable units from the whole. Maybe this is being overly purist, however if we restructure the code this will make unit testing more feasible. It will bring additional benefits of making the code more readable and maintainable.
In this pull request. I have worked on multiple file reading. So, now on it will read multiple files but it will load a single file at a time and this way it will load data quickly.