我有这个测试:
@RunWith(MockitoJUnitRunner.class)
public class myServiceTest {
@InjectMocks
myService subject;
private myService spy;
@Before
public void before() {
spy = spy(subject);
}
@Test
public void testing() {
when(spy.print2()).thenThrow(new RuntimeException()).thenThrow(new RuntimeException()).thenReturn("completed");
spy.print1();
verify(spy, times(3)).print2();
}
Run Code Online (Sandbox Code Playgroud)
然后我有:
@Service("myService")
public class myService extends myAbstractServiceClass {
public String print1() {
String temp = "";
temp = print2();
return temp;
}
@Retryable
public String print2() {
return "completed";
}
}
Run Code Online (Sandbox Code Playgroud)
然后我有这个接口(我的abstractService实现):
public interface myServiceInterface {
@Retryable(maxAttempts = 3)
String print1() throws RuntimeException;
@Retryable(maxAttempts = 3)
String …Run Code Online (Sandbox Code Playgroud) 我目前正在尝试在连接到我的 MacBook Pro 的 Docker 容器上运行 USB Scale 和 USB 条形码扫描仪。我了解如何在 Linux 上使用 --device 或 --privileged 标志来执行此操作,但我似乎无法弄清楚这些设备到底位于我的 mac 上的位置,因为它们不是存储设备。有任何想法吗?