April 2018
Intermediate to advanced
396 pages
11h 8m
English
Let's have a look at how DoubledMultiplierIdentity, which we saw previously, would be tested. One would try to simply mix the trait into a test class and test the methods:
class DoubledMultiplierIdentityTest extends FlatSpec with ShouldMatchers with DoubledMultiplierIdentity
This, however, won't compile and will lead to the following error:
Error:(5, 79) illegal inheritance; superclass FlatSpec is not a subclass of the superclass MultiplierIdentity of the mixin trait DoubledMultiplierIdentityclass DoubledMultiplierIdentityTest extends FlatSpec with ShouldMatchers with DoubledMultiplierIdentity {^
We already talked about this before and the fact that a trait can only be mixed in a class that has the same super class as itself. ...
Read now
Unlock full access