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

improve error logging for JUnit tests #711

Merged
merged 2 commits into from
Jul 3, 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
1 change: 1 addition & 0 deletions org.eclipse.lsp4e.test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
<artifactId>tycho-surefire-plugin</artifactId>
<version>${tycho-version}</version>
<configuration>
<trimStackTrace>false</trimStackTrace>
<testClass>org.eclipse.lsp4e.test.AllTests</testClass>
<useUIHarness>true</useUIHarness>
<useUIThread>true</useUIThread>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
*******************************************************************************/
package org.eclipse.lsp4e.test;

import java.lang.System.Logger.Level;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
Expand All @@ -30,13 +31,23 @@ public class NoErrorLoggedRule extends TestWatcher {

public NoErrorLoggedRule(ILog log) {
this.log = log;
listener = (status, message) -> {
if (status.getSeverity() == IStatus.ERROR) {
final var logger = System.getLogger(log.getBundle().getSymbolicName());
listener = (status, unused) -> {
switch (status.getSeverity()) {
case IStatus.ERROR:
loggedErrors.add(status);
logger.log(Level.ERROR, status.toString(), status.getException());
break;
case IStatus.WARNING:
logger.log(Level.WARNING, status.toString(), status.getException());
break;
case IStatus.INFO:
logger.log(Level.INFO, status.toString(), status.getException());
break;
}
};
}

@Override
protected void starting(Description description) {
super.starting(description);
Expand Down