12 EKİM 2012, Cuma
Nasıl belirli bir yöntem kullanarak Mockito çağrıldı doğrulamak için?
Nasıl bir yöntem olduğunu doğrulamak içindeğilbir nesnenin bağımlılık çağırdı?
Örneğin:
public interface Dependency {
void someMethod();
}
public class Foo {
public bar(final Dependency d) {
...
}
}
Foo ile test:
public class FooTest {
@Test
public void dependencyIsNotCalled() {
final Foo foo = new Foo(...);
final Dependency dependency = mock(Dependency.class);
foo.bar(dependency);
// verify here that someMethod was not called??
}
}
CEVAP
12 EKİM 2012, Cuma
Daha da anlamlı :
import static org.mockito.Mockito.*;
// ...
verify(dependency, never()).someMethod()
Bu özellik belgelerine §4 "Verifying exact number of invocations / at least x / never" never
javadoc here var.
Bunu Paylaş:
Yöntem bir nesne yöntemi içinde oluştu...
Mockito ile iki kez kontrol denilen bi...
Nasıl bir yöntem Adedi olarak DEĞİL, "...
Bir yöntem için geçirilen bağımsız değ...
Belirli bir URL C Professional (Servic...