@Test public void canAddManyListenersPerThread() { LogEventListener listener1 = mock(LogEventListener.class); LogEventListener listener2 = mock(LogEventListener.class); LogEventListener listener3 = mock(LogEventListener.class); SelenideLogger.addListener("simpleReport", listener1); SelenideLogger.addListener("softAsserts", listener2); SelenideLogger.addListener("userProvided", listener3); WebElement webElement = mock(WebElement.class); when(webdriver.findElement(By.cssSelector("div"))).thenReturn(webElement); when(webElement.isDisplayed()).thenReturn(true); $("div").click(); verifyEvent(listener1); verifyEvent(listener2); verifyEvent(listener3); verifyNoMoreInteractions(listener1, listener2, listener3); reset(listener1, listener2, listener3); SelenideLogger.removeListener("simpleReport"); SelenideLogger.removeListener("softAsserts"); $("div").click(); verifyEvent(listener3); verifyNoMoreInteractions(listener1, listener2, listener3); }
@Test public void convertsJavaMethodNameToHumanReadableClause() { assertEquals("click", SelenideLogger.readableMethodName("click")); assertEquals("set value", SelenideLogger.readableMethodName("setValue")); assertEquals("should be", SelenideLogger.readableMethodName("shouldBe")); assertEquals( "converts java method name to human readable clause", SelenideLogger.readableMethodName("convertsJavaMethodNameToHumanReadableClause")); }
@Test public void printsReadableArgumentsValues() { assertEquals("", SelenideLogger.readableArguments(null)); assertEquals("111", SelenideLogger.readableArguments(111)); assertEquals("[1, 2, 3]", SelenideLogger.readableArguments(1, 2, 3)); assertEquals("a", SelenideLogger.readableArguments(new String[] {"a"})); assertEquals("[a, bb]", SelenideLogger.readableArguments(new String[] {"a", "bb"})); assertEquals("null", SelenideLogger.readableArguments(new String[] {null})); assertEquals( "[null, a, null]", SelenideLogger.readableArguments(new String[] {null, "a", null})); }