victorolinasc / junit-formatter

A JUnit XML report exporter for Elixir's ExUnit
https://hexdocs.pm/junit_formatter/
Apache License 2.0
110 stars 37 forks source link

JUnitFormatter does not load and does not do anything #51

Open bvobart opened 3 weeks ago

bvobart commented 3 weeks ago

Hi, I'm trying to use JUnitFormatter in my Elixir 1.17 project, so I followed the steps in the ReadMe, but I notice that no JUnit XML file is being produced, even after setting the relevant config options. I even set print_report_file: true, but I don't see anything about JUnit being printed. Even if I monkey-patch JUnitFormatter's init/1 to do an IO.puts("JUnitFormatter initialized") I do not see this being printed, which leads me to believe that for some reason, JUnitFormatter is not loading.

Here's the relevant parts from my mix.exs:

defmodule NLdoc.MixProject do
  use Mix.Project

  ...

  def test_coverage() do
    [
      # ignore modules generated by libraries that we use.
      ignore_modules: [
        ~r/NLdoc\.Validation\.Severity\..*/,
        ~r/Jason\.Encoder\..*/
      ],
      # TODO: increase eventually
      summary: [threshold: 75]
    ]
  end

  defp deps do
    [
      ...

      # Testing: mocking, snapshot testing, reporting
      {:mimic, "~> 1.7", only: :test},
      {:mneme, ">= 0.0.0", only: [:test]},
      {:junit_formatter, "~> 3.4", only: [:test]},

      ...
    ]
  end
end

My test/test_helper.exs:

Mimic.copy(NLdoc.Spec.Document)
Mimic.copy(NLdoc.Validation)

ExUnit.configure(formatters: [JUnitFormatter, ExUnit.CLIFormatter])
ExUnit.start()
Mneme.start()

The JUnitFormatter config in my config.exs file:

if config_env() == :test do
  config :junit_formatter,
    automatic_create_dir?: true,
    include_filename?: true,
    include_file_line?: true,
    print_report_file: true,
    report_dir: Mix.Project.project_file() |> Path.dirname() |> Path.join("cover"),
    report_file: "junit.xml"
end

Is this a bug in JUnitFormatter or am I doing something wrong here?