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

Generate report file based on TestResult #55

Closed
wants to merge 1 commit into from

Conversation

kandoeniko
Copy link

  • 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

@kandoeniko kandoeniko force-pushed the master branch 3 times, most recently from e366846 to f3e658d Compare April 16, 2019 07:47
- 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 {
Copy link
Contributor

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?

Copy link
Author

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)
Copy link
Contributor

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

Copy link
Author

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'
Copy link
Contributor

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

Copy link
Author

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'
Copy link

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

Copy link
Author

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..")
Copy link

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")?

Copy link
Author

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()) {
Copy link

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

Copy link
Author

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()) {
Copy link

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()

Copy link
Author

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
Copy link

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?

Copy link
Author

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

@timotei
Copy link
Contributor

timotei commented Apr 19, 2019

@kandoeniko Seems we need to update this code to use the other new plugin, no?

@muryoh
Copy link
Contributor

muryoh commented Apr 23, 2019

How much of the logic around gradle-extentreports-dotnet-plugin is going to be kept?
I wonder if it's a good idea for this plugin to have any - gradle plugins often seem to opt for a very "separation of concerns" approach

Like this plugin could only be around nunit (like it is now)
And ppl who want extentreports would then apply a plugin that adds configuration on top of it to add it

Just asking/wondering if there's any thought about that :-)

@kandoeniko
Copy link
Author

@kandoeniko Seems we need to update this code to use the other new plugin, no?

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

@kandoeniko
Copy link
Author

@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.

@kandoeniko
Copy link
Author

Closing pull request as a new plugin with this functionality will be built.

@kandoeniko kandoeniko closed this May 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants