当myMethod从junit执行时,我需要跳过下面的s3Client行。MyClass不会被模拟,myMethod也不会:
MyClass {
myMethod(String bucketName, String path) {
// do stuff
// skip below when mocked in junit
s3Client.deleteObject(new DeleteObjectRequest(bucketName, path));
// more stuff
{
{
在junit中我有:
s3Client = mock(AmazonS3.class);
when(s3Client.deleteObject(any(DeleteObjectRequest.class))).thenReturn(null);
“when”不编译:
when(T) cannot be applied to void. reason: no instances of type variable T exist so that void conforms to T.
同样,我只需要跳过这一行时,从一个junit。任何解决方案赞赏。谢谢。
1条答案
按热度按时间fkaflof61#
这起了作用: