-
Notifications
You must be signed in to change notification settings - Fork 20
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
Generate report file based on TestResult #55
Conversation
e366846
to
f3e658d
Compare
- use the extent-report framework - generate report once NUnit finished generating the report - set the ignoreFailures to true by default because if an exception is thrown the task will not be finalized by generating the report; however take the flag into consideration a bit later in the workflow - added unit tests for report generation - fixed unit test to check the new behaviour
|
||
import org.gradle.api.tasks.Exec | ||
|
||
class ReportGenerator extends Exec { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it seems it worth to be a separate gradle plugin?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will move the entire code to https://github.com/Ullink/gradle-extentreports-dotnet-plugin and do the followups there.
@@ -9,6 +9,10 @@ class NUnitPlugin implements Plugin<Project> { | |||
project.apply plugin: 'nunit-base' | |||
|
|||
Task defaultNUnitTask = project.task('nunit', type: NUnit) | |||
|
|||
Task reportingTask = project.task('nunitReport', type: ReportGenerator) | |||
defaultNUnitTask.finalizedBy(reportingTask) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it might not be working for every project, as if opencover is enabled, nunit is not executed but opencover will invoke nunit instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed, subscribing to both OpenCover and Nunit tasks. Thank you for the really good remark!
class ReportGenerator extends Exec { | ||
|
||
def ExtentReportType = 'v3html' | ||
def ExtentReportDownloadUrl = 'https://github.com/extent-framework/extentreports-dotnet-cli/archive' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's better to download from https://www.nuget.org/api/v2/package/extent/0.0.3 so we can update the version easily
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
def ExtentReportType = 'v3html' | ||
def ExtentReportDownloadUrl = 'https://github.com/extent-framework/extentreports-dotnet-cli/archive' | ||
def ExtentReportZipName = 'master.zip' | ||
def ExtentReportExecutablePath = 'extentreports-dotnet-cli-master/dist/extent.exe' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[minor] Java constants should be UPPER_CASE
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@Override | ||
protected void exec() { | ||
if (isTestResultFileAvailable()) { | ||
project.logger.info("Generating the report for the Test Results..") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[minor] Maybe log the nunit
word too ("nunit test results")?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
NUnit nunit = project.tasks.nunit | ||
|
||
File testResultPath = nunit.getTestReportPath() | ||
if (!testResultPath.exists()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or just return testResultPath.exists
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
} | ||
|
||
def extentReportExecutable = new File(extentReportCacheDir, ExtentReportExecutablePath) | ||
if (!extentReportExecutable.exists()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or just return extentReportExecutable.exists()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -1,6 +1,7 @@ | |||
package com.ullink |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about adding an integration-like test which executes the task on a packaged nunit result.xml resource and asserts the content of the generated HTML report?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will try to add one
@kandoeniko Seems we need to update this code to use the other new plugin, no? |
How much of the logic around gradle-extentreports-dotnet-plugin is going to be kept? Like this plugin could only be around nunit (like it is now) Just asking/wondering if there's any thought about that :-) |
Yes, if we choose to go in the direction of the new plugin we will not need this one anymore. Instead, we will have to apply the gradle-extent-report-plugin |
@muryoh I will abandon this pull request and focus only on gradle-extentreports-dotnet-plugin in order to have the logic for generating the report only there and leave the gradle-nunit-plugin as clean as possible. |
Closing pull request as a new plugin with this functionality will be built. |
generating the report
because if an exception is thrown the task
will not be finalized by generating the report;
however take the flag into consideration a bit
later in the workflow