In that case, a new singleton object will be created.
在这种情况下,一个新的单例对象会被创建。
Instead, Scala supports a singleton object construct to support those cases where exactly one instance of a type is needed.
相反,Scala支持单例模式,可以应用于那些一种类型只有一个实例的情况。
Now, we can call the reset method to start off each test run to ensure we are going through the initialization code for the singleton object on every test run.
现在,我们可以在每次测试之前调用reset方法,保证我们在每次测试过程中都会先执行singleton对象的初始化代码。
应用推荐