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

Add HTMLReporter to Generate HTML Based on XML #2130

Merged
merged 8 commits into from
Apr 11, 2021
Merged

Add HTMLReporter to Generate HTML Based on XML #2130

merged 8 commits into from
Apr 11, 2021

Conversation

caramelomartins
Copy link
Contributor

This PR has the aim of tackling #2011 and adds a listener named HTMLReporter which will produce HTML reports based on the XML generated by the JunitXmlReporter. It has the following results:

image

image

It currently generates some very basic HTML reports but they have the essential functionality of showing the test classes that have failed and the tests that have failed.

The tests still need some working on but I thought it would be important to open this PR early to get some early feedback because it is getting quite big, due mostly to the fact that I had to add an entire module containing the HTMLReporter.

@caramelomartins caramelomartins changed the title Add HTMLReporter to Generate HTML Based on XML Add HTMLReporter to Generate HTML Based on XML Feb 27, 2021
id("java")
kotlin("multiplatform")
id("java-library")
id("org.jetbrains.kotlin.plugin.spring") version Libs.kotlinVersion
Copy link
Member

Choose a reason for hiding this comment

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

Is spring needed ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't believe so, this must be a typo. I'll check it and remove it.

import java.nio.file.Paths
import java.nio.file.StandardOpenOption

class HtmlReporter(
Copy link
Member

Choose a reason for hiding this comment

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

The project listener that locates the test data, and the class that generates HTML could be separated since they are different things. The former could invoke the latter.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't mind that. What would we call these? HtmlReporter and HtmlGenerator?

Copy link
Member

Choose a reason for hiding this comment

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

HtmlWriter maybe for the thing that does the html generator and HtmlReporter yeah for the listener class.

@caramelomartins
Copy link
Contributor Author

caramelomartins commented Mar 20, 2021

@sksamuel I've refactored this code a bit. I moved the logic to generate the HTML to a separate class called HtmlWriter. I've also improve the code's readability by creating some data classes that we can use to group the data for each of the test classes and then we can call HtmlWriter based on that, instead of passing around XML elements. I believe this merits some tests but I'm having trouble thinking up of ways to write tests for HTML code produce...it won't be trivial. Let me know what you think about how it is now, thank you!

@caramelomartins
Copy link
Contributor Author

Thanks for the approve @sksamuel. Are you happy if I merge this?

@sksamuel
Copy link
Member

sksamuel commented Apr 11, 2021 via email

@caramelomartins
Copy link
Contributor Author

I cannot do that, I'm sorry, because I don't seem to have permissions to merge PRs in Kotest's repository.

@sksamuel sksamuel merged commit d7e24e8 into kotest:master Apr 11, 2021
@sksamuel
Copy link
Member

Yes of course, I'm thinking I'm at work :)

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.

2 participants