-
Notifications
You must be signed in to change notification settings - Fork 16
Use mock object to replace input in coverage
in Modbat.scala
#69
Comments
Once we have the mocks in place, we can uncomment the corresponding tests in |
In order to use mock, I need to add dependencies to Gradle but scalamock is only allowed to import in test/scala, not in main/scala Also, I got en exception after run chooseTest with this search feature:
Currently, I am not sure why it has NoClassDefFoundError. |
However, I wrote a small program to test Mock as a fake readLine with the same way I did for modbat, and that program works fine... |
Have you tried a build from scratch? Perhaps a dependency was wrong. |
If you have trouble getting mocking to work, you could also code this up explicitly:
In that case, we don't need mocking. For this to work, you'll have to use the new unit test framework, which will be ready in a few days (I hope). |
You can set "isUnitTest" to "true" by hand somewhere in the code in the meantime, to make this work. |
ok I will try this after I restart my laptop. It is too slow now... |
I fix this by using another configuration: So, if doing tests, we can set example:
Please see if it is fine with this way. I have pused to branch issue-69. |
OK, we can use this for the time being, but later we should change this back. (All unit tests will share Modbat.isUnitTest to implement this type of feature.) |
Displaying path coverage is interactive to allow a user to select what parts of the coverage to display. This cannot be used with automated testing; the tests are currently disabled due to this.
We can use mock testing in case
Modbat.isUnitTest
istrue
.See:
http://www.scalatest.org/user_guide/testing_with_mock_objects
https://scalamock.org/user-guide/advanced_topics/
The mock should replace
readLine
and return the right sequence ofq
s and other inputs.The text was updated successfully, but these errors were encountered: