Skip to content

Commit

Permalink
add test for TracedCommandExecutor
Browse files Browse the repository at this point in the history
  • Loading branch information
navin772 committed Dec 16, 2024
1 parent 07e0c64 commit 0bcbc4e
Showing 1 changed file with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package org.openqa.selenium.remote;

import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
Expand Down Expand Up @@ -48,7 +49,7 @@ class TracedCommandExecutorTest {
public void createMocksAndTracedCommandExecutor() {
MockitoAnnotations.initMocks(this);
when(tracer.getCurrentContext()).thenReturn(traceContext);
when(traceContext.createSpan("command")).thenReturn(span);
when(traceContext.createSpan(anyString())).thenReturn(span);
tracedCommandExecutor = new TracedCommandExecutor(commandExecutor, tracer);
}

Expand Down Expand Up @@ -109,4 +110,18 @@ void canCreateSpanWithCommandName() throws IOException {
verify(span, times(1)).close();
verifyNoMoreInteractions(span);
}

@Test
void canCreateSpanWithCommandNameAsSpanName() throws IOException {
SessionId sessionId = new SessionId(UUID.randomUUID());
Command command = new Command(sessionId, "findElement");

tracedCommandExecutor.execute(command);

verify(traceContext).createSpan("findElement");
verify(span).setAttribute("sessionId", sessionId.toString());
verify(span).setAttribute("command", "findElement");
verify(span).close();
verifyNoMoreInteractions(span);
}
}

0 comments on commit 0bcbc4e

Please sign in to comment.