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

Comply with html reporter format #160

Merged
merged 48 commits into from Mar 20, 2019

Conversation

hugo-vrijswijk
Copy link
Member

Closes #29

What it does

Supports the new HTML reporter schema. (stryker-mutator/mutation-testing-elements#1)

How it works

Adds some new case classes that when converted to JSON, comply with the schema. Root case class has a toJson method that returns a io.circe JSON object. Case classes do not have html in their names, as the schema is not html-report specific (though that is the only implementation for now).

Also adds a mapper that converts the MutantRunResult to the case classes for the HTML report.

This PR is to a new branch, feat-html-reporter instead of the already existing branch HTML-reporter as I have made a lot of changes, merged master, etc, which would create a really, really ugly diff.

legopiraat and others added 30 commits August 6, 2018 19:39
…o html report + fix bug with health range numbers
import stryker4s.report.model.MutantStatus.MutantStatus
import stryker4s.report.model._

trait MutantRunResultMapper {
Copy link
Contributor

Choose a reason for hiding this comment

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

I have a couple of thoughts about this trait.

  1. There's one test that covers all the methods, shouldn't we split this up more? That way if a test fails it's easier to identify where the bug is, but I'm not sure how important that is.
  2. If we're not going to do nr 1, all of these methods can be marked private except toReport, if I'm correct.
  3. The method names slightly throw me off. i.e. toLocation makes more sense as an extension method. Now for example you're calling toMutantStatus, but I'm thinking: "you're going to MutantStatus... from where exactly?" if that makes sense. To me something like mapRunResultToMutantStatus makes more sense.

Copy link
Member Author

Choose a reason for hiding this comment

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

1. There's one test that covers all the methods, shouldn't we split this up more? That way if a test fails it's easier to identify where the bug is, but I'm not sure how important that is.

I agree. The single test is a bit massive. The thing is though is that the 'top' map function calls the other functions anyway. So then having tests for the 'smaller' functions is a bit redundant

3. The method names slightly throw me off. i.e. `toLocation` makes more sense as an extension method. Now for example you're calling `toMutantStatus`, but I'm thinking: "you're going to MutantStatus... from where exactly?" if that makes sense. To me something like `mapRunResultToMutantStatus` makes more sense.

Hmm, I feel like the "from where" is already apparent from it being given as a parameter (as well as the signature). Having names like mapRunResultToMutantStatus will get pretty big and unreadable. I agree the names could be better though

core/src/main/scala/stryker4s/report/model/Position.scala Outdated Show resolved Hide resolved
docs/CONFIGURATION.md Outdated Show resolved Hide resolved
@nicojs
Copy link
Member

nicojs commented Feb 27, 2019

Are you guys checking in the build result of mutation-testing-elements? Please don't do that! Suggestion: add an SBT plugin to download the file in the build 🙈

@hugo-vrijswijk
Copy link
Member Author

Are you guys checking in the build result of mutation-testing-elements? Please don't do that! Suggestion: add an SBT plugin to download the file in the build 🙈

Cool idea! I agree it's a bit ugly to have the generated js in source control, but I'm not sure what the alternative should be. Ideally, the file would be downloaded at the same as the other dependencies. But to do that we'd have to upload it to maven central or something.

If we were to download it with an SBT plugin we still need to put the file somewhere. Putting it in resources means we'd have to add it to gitignore (not a terrible idea), putting it in target/... opens up a whole new can of worms.

Alternatively, maybe something like webjars could be useful for us.

@nicojs
Copy link
Member

nicojs commented Feb 27, 2019

If we were to download it with an SBT plugin we still need to put the file somewhere. Putting it in resources means we'd have to add it to gitignore (not a terrible idea)

Sounds like a good first step. As a performance improvement: don't download it if the file is already there and remove it on sbt clean (or whatever the alternative is to mvn clean).

Ideally, the file would be downloaded at the same as the other dependencies. But to do that we'd have to upload it to maven central or something.

Sounds good to me. You could also create a package.json file and simply run npm install. You then manage the version from there. The file can be found in node_modules/mutation-testing-elements/dist/mutation-test-elements.js.

@hugo-vrijswijk
Copy link
Member Author

You could also create a package.json file and simply run npm install

Not sure if I like having to install npm as a requirement for our build. For now, I've made a PR to add it as a dependency

@nicojs
Copy link
Member

nicojs commented Feb 27, 2019

Not sure if I like having to install npm as a requirement for our build

Yeah, I agree that multiple development stacks as a build requirement isn't the most elegant solution. Glad to see there is a way around it with webjars.

@hugo-vrijswijk
Copy link
Member Author

@Wmaarts I've made some changes. Please have a look and see if you agree

@hugo-vrijswijk hugo-vrijswijk added the enhancement New feature or request label Mar 20, 2019
Copy link
Contributor

@Wmaarts Wmaarts left a comment

Choose a reason for hiding this comment

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

Looks good! I only have questions tbh.

case _: Survived => MutantStatus.Survived
case _: Killed => MutantStatus.Killed
case _: NoCoverage => MutantStatus.NoCoverage
case _: TimedOut => MutantStatus.Timeout
case _: Error => MutantStatus.CompileError
}

private[this] def fileContentAsString(path: Path)(implicit config: Config): String =
private def fileContentAsString(path: Path)(implicit config: Config): String =
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason this is private instead of private[this]? (I'm actually not sure about the difference. 🙈 )

Copy link
Member Author

Choose a reason for hiding this comment

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

There's no real reason other than consistency. private means objects of other types can not access it. private[this] means objects of the same type also cannot access it. So it's slightly tighter encapsulation. (You can also have protected[com.packagename] for example). It's explained better here

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think there's consistency on this throughout stryker4s though.

Copy link
Member Author

Choose a reason for hiding this comment

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

True. But now there is within the class

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess we'll save this discussion for later then. x)

@hugo-vrijswijk hugo-vrijswijk merged commit 231ce57 into feat-html-reporter Mar 20, 2019
@ghost ghost removed the in progress label Mar 20, 2019
@hugo-vrijswijk hugo-vrijswijk deleted the Comply-html-reporter-format branch March 20, 2019 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants