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

update JSErrorsCollectorListener and JSErrorsExtension #3

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 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
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ public void afterTestExecution(ExtensionContext context) {

// Check for JS errors assertion boolean flag.
// Skip error throwing in case of negative unit test.
if (isAssertJSErrorsEnabled(context) && getJSErrorsFromLogEntries(logEntries).anyMatch(e -> true)
if (isAssertJSErrorsEnabled(context) && getJSErrorsFromLogEntries(logEntries).count()!=0
&& context.getTestClass().toString().contains("com.github.automatedowl")
&& context.getRequiredTestMethod().getName().equals("referenceErrorTest")) {
assertThrows(WebDriverException.class, ()->{
throw new WebDriverException(JS_ERRORS_EXCEPTION_STRING);
});
} else if (isAssertJSErrorsEnabled(context) && getJSErrorsFromLogEntries(logEntries).anyMatch(e -> true)) {
throw new WebDriverException(JS_ERRORS_EXCEPTION_STRING);
} else if (isAssertJSErrorsEnabled(context) && getJSErrorsFromLogEntries(logEntries).count()!=0) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the purpose of the change from anyMatch to count? @mkulikov

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logic above returns true when there is items in list, which is more confusing than simple check for count != 0

throw new WebDriverException(getJSErrorsFromLogEntries(logEntries).map(LogEntry::getMessage).collect(Collectors.joining("\n")));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,17 @@ public void afterInvocation(IInvokedMethod iInvokedMethod, ITestResult iTestResu
// Check for JS errors assertion boolean flag.
// Skip error throwing in case of negative unit test.
if (isAssertJSErrorsEnabled(
iInvokedMethod) && getJSErrorsFromLogEntries(logEntries).anyMatch(e -> true)
iInvokedMethod) && getJSErrorsFromLogEntries(logEntries).count()!=0
&& iInvokedMethod
.getTestMethod().getTestClass().toString().contains("com.github.automatedowl")
&& iInvokedMethod
.getTestMethod().getConstructorOrMethod().getMethod().getName().equals("referenceErrorTest")) {
// Don't throw exception on unit test.
}
else if (isAssertJSErrorsEnabled(
iInvokedMethod) && getJSErrorsFromLogEntries(logEntries).anyMatch(e -> true)) {
iInvokedMethod) && getJSErrorsFromLogEntries(logEntries).count()!=0) {
logger.severe(JS_ERRORS_EXCEPTION_STRING);
iTestResult.setStatus(ITestResult.FAILURE);
throw new WebDriverException(getJSErrorsFromLogEntries(logEntries).map(LogEntry::getMessage).collect(Collectors.joining("\n")));
}
}
}
Expand Down