Dart, individual testing methods

I have a library that is quite large, but provides only a very tiny API that simplifies use and training for new users. I would like to save my library this way, but I also want to have as much unit test as possible, I would like to be able to directly unit test all my classes, but as far as I can tell I can only unit test the public library API.

I can, of course, write unit tests to fully test public methods that will effectively indirectly test all the underlying private classes, but if the test fails, it may mean that there are a lot of digits in the private code to find out where something went wrong, instead of having unit tests for each individual private class, so when something goes wrong, you can immediately see what went wrong and where.

Is there a design template that will help in this situation, or a unit testing method that should be written for private classes and dart methods?

+5
source share
1 answer

If you move your private classes to a separate library in one application, you can make them public and test them. Then you import this library into your current library, rather than exporting it (therefore, the user of your library still cannot use your other classes unless he imports this other library).

+7
source

All Articles