Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logging improved and stored in separate folders (one for each TJob) #56

Merged
merged 3 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ stage('TEARDOWN-Infrastructure') {
post {
always {
archiveArtifacts artifacts: 'artifacts/*.csv', onlyIfSuccessful: true
//archiveArtifacts artifacts: 'target/testlogs/**/*.*', onlyIfSuccessful: false //COMMENTED UNTIL LOGS IMPROVED
archiveArtifacts artifacts: 'target/testlogs/**/*.*', onlyIfSuccessful: false
archiveArtifacts artifacts: 'target/containerlogs/**/*.*', onlyIfSuccessful: false
}//EndAlways
}//EndPostActions
Expand Down
28 changes: 10 additions & 18 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@
<junit.platform.version>1.0.0</junit.platform.version>

<selenium-jupiter.version>5.0.0</selenium-jupiter.version>

<slf4j.version>2.0.9</slf4j.version>


<junit-jupiter-engine.version>5.10.1</junit-jupiter-engine.version>

<junit-jupiter-params.version>5.10.1</junit-jupiter-params.version>
Expand All @@ -60,7 +58,11 @@
<maven-surefire-plugin.version>3.2.2</maven-surefire-plugin.version>

<jacoco-maven-plugin.version>0.8.7</jacoco-maven-plugin.version>


<slf4j-api.version>2.0.9</slf4j-api.version>

<log4j-slf4j2-impl.version>2.22.0</log4j-slf4j2-impl.version>

<!-- Plugins Jacoco -->
<jacoco.version>0.8.11</jacoco.version>
<sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
Expand Down Expand Up @@ -114,7 +116,6 @@
<version>5.10.1</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand All @@ -127,32 +128,23 @@
<version>${selenium-jupiter.version}</version>
<scope>test</scope>
</dependency>


<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>${webdrivermanager.version}</version>
<scope>test</scope>
</dependency>


<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
<scope>test</scope>
<version>${slf4j-api.version}</version>
</dependency>
<!-- Solution for error: https://examples.javacodegeeks.com/solving-slf4j-failed-load-class-org-slf4j-impl-staticloggerbinder/
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".-->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
<version>${slf4j.version}</version>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j2-impl</artifactId>
<version>${log4j-slf4j2-impl.version}</version>
<scope>test</scope>
</dependency>


<!-- RETORCH DEPENDENCY-->
<dependency>
<groupId>io.github.giis-uniovi</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.openqa.selenium.logging.LogEntries;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.FileInputStream;
import java.io.IOException;
Expand All @@ -34,7 +35,7 @@ public class BaseLoggedTest {
//protected static final String host= SetUp.getHost();
public static final String FIREFOX = "firefox";
public static final String EDGE = "edge";
protected final static Logger log = getLogger(lookup().lookupClass());
public static final Logger log = LoggerFactory.getLogger(BaseLoggedTest.class);
protected static final Class<? extends WebDriver> chrome = ChromeDriver.class;
protected static final Class<? extends WebDriver> firefox = FirefoxDriver.class;
public static String TEACHER_BROWSER;
Expand All @@ -48,6 +49,7 @@ public class BaseLoggedTest {
protected static Properties properties;
protected static String TEST_NAME = "DEFAULT";
protected static String TJOB_NAME = "TJobDef";
protected final static int DEPTH = 3;

public WebDriver driver;
protected BrowserUser user;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.openqa.selenium.support.ui.ExpectedCondition;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.time.Duration;

Expand All @@ -30,7 +31,7 @@

public class BrowserUser {

static final Logger log = getLogger(lookup().lookupClass());
public static final Logger log = LoggerFactory.getLogger(BrowserUser.class);
protected final String clientData;
protected final int timeOfWaitInSeconds;
protected WebDriver driver;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -20,7 +21,7 @@

public class CourseNavigationUtilities {

public static final Logger log = getLogger(CourseNavigationUtilities.class);
private static final Logger log = LoggerFactory.getLogger(CourseNavigationUtilities.class);

public static String newCourse(WebDriver wd, String courseName) throws ElementNotFoundException { //37 lines
NavigationUtilities.toCoursesHome(wd);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -21,7 +22,7 @@


public class ForumNavigationUtilities {
final static Logger log = getLogger(lookup().lookupClass());
private static final Logger log = LoggerFactory.getLogger(ForumNavigationUtilities.class);

public static boolean isForumEnabled(WebElement forumTabContent) { //6lines
log.info("Checking if the forum is enabled");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;

Expand All @@ -17,7 +18,7 @@


public class NavigationUtilities {
final static Logger log = getLogger(lookup().lookupClass());
private static final Logger log = LoggerFactory.getLogger(NavigationUtilities.class);

public static boolean amINotHere(WebDriver wd, String url) {
log.info("Checking if the browser is in the URL: {}", url);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import static com.fullteaching.e2e.no_elastest.common.Constants.*;
import static java.lang.invoke.MethodHandles.lookup;
Expand All @@ -20,7 +21,7 @@
public class UserUtilities {


final static Logger log = getLogger(lookup().lookupClass());
private static final Logger log = LoggerFactory.getLogger(UserUtilities.class);


public static WebDriver checkLogin(WebDriver wd, String user) throws NotLoggedException, BadUserException, ElementNotFoundException { //12 lines
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@
@Tag("e2e")
@DisplayName("E2E tests for FullTeaching Login Session")
class LoggedForumTest extends BaseLoggedTest {


final static Logger log = getLogger(lookup().lookupClass());
protected final String courseName = "Pseudoscientific course for treating the evil eye";
protected final String[] months = {"January", "February", "March", "April",
"May", "June", "July", "August", "September",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
@ExtendWith(SeleniumJupiter.class)
class LoggedLinksTests extends BaseLoggedTest {

protected final static int DEPTH = 3;
final static Logger log = getLogger(lookup().lookupClass());


public LoggedLinksTests() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@

class UnLoggedLinksTests extends BaseLoggedTest {

protected final static int DEPTH = 3;

final static Logger log = getLogger(lookup().lookupClass());


public UnLoggedLinksTests() {
super();
}
Expand All @@ -38,7 +33,6 @@ public static Stream<Arguments> data() throws IOException {
return ParameterLoader.getTestUsers();
}


@ParameterizedTest
@MethodSource("data")
@Resource(resID = "LoginService", replaceable = {})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
@ExtendWith(SeleniumJupiter.class)
class UserTest extends BaseLoggedTest {


public static Stream<Arguments> data() throws IOException {
return ParameterLoader.getTestUsers();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import static java.lang.invoke.MethodHandles.lookup;
import static org.slf4j.LoggerFactory.getLogger;

public class Click {

public static final Logger log = getLogger(lookup().lookupClass());
private static final Logger log = LoggerFactory.getLogger(Click.class);

public static WebDriver here(WebDriver wd, int x, int y) {
Actions builder = new Actions(wd);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.junit.jupiter.params.provider.Arguments;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.util.Collection;
Expand All @@ -13,7 +14,7 @@

public class ParameterLoader {

protected static final Logger log = getLogger(lookup().lookupClass());
private static final Logger log = LoggerFactory.getLogger(ParameterLoader.class);

public static Stream<Arguments> getTestUsers() throws IOException {
//Be careful! Don't change it despite the analyzer recommends that!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.logging.LogEntries;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Date;
import java.util.concurrent.TimeUnit;
Expand All @@ -19,7 +20,7 @@

public class SetUp {

final static Logger log = getLogger(lookup().lookupClass());
private static final Logger log = LoggerFactory.getLogger(SetUp.class);

public static void tearDown(WebDriver driver) {
if (driver != null) {
Expand Down
21 changes: 21 additions & 0 deletions src/test/resources/log4j2.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
<Appenders>
<Console name="ConsoleAppender" target="SYSTEM_OUT">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n%throwable"/>
</Console>
<File name="FileAppender" fileName="target/testlogs/log${sys:tjob_name:-testinglocal}-test.log">
<PatternLayout pattern="%d [%t] %-5level %logger{36} - %msg%n%throwable"/>
</File>
</Appenders>
<Loggers>
<Root level="info">
<AppenderRef ref="ConsoleAppender"/>
<AppenderRef ref="FileAppender"/>
</Root>
<Logger name="giis" level="debug" additivity="false">
<AppenderRef ref="ConsoleAppender"/>
<AppenderRef ref="FileAppender"/>
</Logger>
</Loggers>
</Configuration>
7 changes: 0 additions & 7 deletions src/test/resources/simplelogger.properties

This file was deleted.