Skip to content

Commit 0bcbc4e

Browse files
committed
add test for TracedCommandExecutor
1 parent 07e0c64 commit 0bcbc4e

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

java/test/org/openqa/selenium/remote/TracedCommandExecutorTest.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
package org.openqa.selenium.remote;
1919

20+
import static org.mockito.ArgumentMatchers.anyString;
2021
import static org.mockito.Mockito.times;
2122
import static org.mockito.Mockito.verify;
2223
import static org.mockito.Mockito.verifyNoMoreInteractions;
@@ -48,7 +49,7 @@ class TracedCommandExecutorTest {
4849
public void createMocksAndTracedCommandExecutor() {
4950
MockitoAnnotations.initMocks(this);
5051
when(tracer.getCurrentContext()).thenReturn(traceContext);
51-
when(traceContext.createSpan("command")).thenReturn(span);
52+
when(traceContext.createSpan(anyString())).thenReturn(span);
5253
tracedCommandExecutor = new TracedCommandExecutor(commandExecutor, tracer);
5354
}
5455

@@ -109,4 +110,18 @@ void canCreateSpanWithCommandName() throws IOException {
109110
verify(span, times(1)).close();
110111
verifyNoMoreInteractions(span);
111112
}
113+
114+
@Test
115+
void canCreateSpanWithCommandNameAsSpanName() throws IOException {
116+
SessionId sessionId = new SessionId(UUID.randomUUID());
117+
Command command = new Command(sessionId, "findElement");
118+
119+
tracedCommandExecutor.execute(command);
120+
121+
verify(traceContext).createSpan("findElement");
122+
verify(span).setAttribute("sessionId", sessionId.toString());
123+
verify(span).setAttribute("command", "findElement");
124+
verify(span).close();
125+
verifyNoMoreInteractions(span);
126+
}
112127
}

0 commit comments

Comments
 (0)