# Split-by=timings on Elixir project fails to find stored timings, possibly missing file names in JUnit XML

**URL:** <https://discuss.circleci.com/t/split-by-timings-on-elixir-project-fails-to-find-stored-timings-possibly-missing-file-names-in-junit-xml/34813>\
**Category:** Programming Languages\
**Tags:** 2.0, parallelism\
**Created:** [March 5, 2020, 9:37pm UTC](https://discuss.circleci.com/t/split-by-timings-on-elixir-project-fails-to-find-stored-timings-possibly-missing-file-names-in-junit-xml/34813 "2020-03-05T21:37:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![danadaldoss](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/danadaldoss/32/23856_2.png) [@danadaldoss](https://discuss.circleci.com/u/danadaldoss)\
**Post date:** [March 5, 2020, 9:37pm UTC](https://discuss.circleci.com/t/split-by-timings-on-elixir-project-fails-to-find-stored-timings-possibly-missing-file-names-in-junit-xml/34813/1 "2020-03-05T21:37:05Z")

</div>

Hey all,

I am trying to get `--split-by=timings` to work on an Elixir project but I keep getting the following error:

```auto
$ TESTFILES=$(circleci tests glob "test/**/*_test.exs" | circleci tests split --split-by=timings --show-counts)

Read 359 lines of autodetect(s)
Error autodetecting timing type, falling back to weighting by name. Autodetect no matching filename or classname. If file names are used, double check paths for absolute vs relative.
Example input file: "test/channels/filter_header_channel_test.exs"
Example file from timings: ""
Bucket 0: assigning 90 autodetect(s), total weight 90

```

When I SSH into a container, here’s what the very end of `.circleci-task-data/circle-test-results/results.json` look like:

```auto
{"classname":"Elixir.Foo.ControllerTest","file":null,"name":"test some stuff","result":"success","run_time":0.5231,"message":null,"source":"unknown","source_type":"unknown"}
{"classname":"Elixir.FooProject.SomeTest","file":null,"name":"test some stuff","result":"success","run_time":0.0038,"message":null,"source":"unknown","source_type":"unknown"}],

"files":["results.xml","results.xml","results.xml","results.xml"],"exceptions":[]}

```

Note that all of the test cases in that file have `"file":null`.  
(“files” seems to be an aggregation from the 4 containers I’m running (`parallelism: 4`)

I have compared notes with someone running a Ruby project, and the JSON in his test container looks like:

```auto
{
  "tests": [
    {"classname": "...", "file": "ACTUAL/FILE/NAME", "name": "...", "result": "...", "run_time": "...", "message": "...", "source": "...", "source_type": "..."},
    ...
  ]
}

```

And, as noted in the sample, all of his test cases have a file name.

Now, I assume that `results.json` is created out of the JUnit formatter results that get saved as part of the `store_test_results` step in the build. Looking into the XML that gets stored after a build, and comparing notes again with the Ruby project, it appears that for Ruby/Rspec projects, `RspecJunitFormatter` outputs XML that includes a `file` attribute, whereas the XML outputted from Elixir’s JUnit Formatter ([GitHub - victorolinasc/junit-formatter: A JUnit XML report exporter for Elixir's ExUnit](https://github.com/victorolinasc/junit-formatter)) does **NOT** have that field. Compare:

### rspec.xml

```auto
<testsuite>
    <testcase classname="..." name="..." file="..." time="..." />
</testsuite>

```

VS.

### exunit.xml

```auto
<testsuite>
    <testcase classname="Elixir.FooProject.SomeQueryTest" name="test where stuff happens" time="0.1038"/>
</testsuite>

```

Okay, so one includes file names, the other does not. CircleCI’s `split` function has a `--timings-type` flag that can be passed-in to tell the splitter to either look for `filename` or `classname`. However, adding `--timings-type=classname` to the command does not fix the issue, instead, it causes a new error:

```auto
Read 359 lines of classname(s)
No timing found for "test/channels/test1.exs"
No timing found for "test/channels/test2.exs"
...
No timing found for "test/views/test200.exs"
No timing found for "test/views/test201.exs"
Bucket 0: assigning 90 classname(s), total weight 2799000 

```

Which leads me to believe that CircleCI’s `split` utility **requires a file name in the JUnit XML** , which currently is not available in Elixir’s `junit-formatter`.

Can someone confirm this or not? Am I missing something in my configuration?

* * *

### Config.yml

For thoroughness, here are the relevant parts of my config file:

```auto
version: 2.1
jobs:
  build:
    docker:
      - image: circleci/elixir:1.8.2-browsers
        environment:
          MIX_ENV: test
      - image: redis:4.0.14
      - image: circleci/postgres:10.10-alpine-postgis
        environment:
          POSTGRES_USER: postgres
          POSTGRES_PASSWORD:
    working_directory: /home/circleci/my_project
    parallelism: 4
    steps:
      - checkout

      ... caching stuff ...

      - run: TESTFILES=$(circleci tests glob "test/**/*_test.exs" | circleci tests split --split- 
             by=timings --timings-type=classname --show-counts)

      - run: mix test ${TESTFILES} --trace

      - store_test_results:
          path: test-results/exunit

```

* * *

Other knowns:

- Aside from timings not working, build run successfully with parallelization and files are split by filename.
- In our project, timings were actually working until December 9th, 2019, when they suddenly stopped. We had not implemented JUnit and were not using workflows.
- As of CircleCI v2.0, projects are expected to output their own JUnit XML.
- Splitting by timing data should work regardless of using workflows or not.

Additionally, I would draw your attention to a comment made in the RspecJunitFormatter repo:  
[https://github.com/sj26/rspec\_junit\_formatter/pull/70](https://github.com/sj26/rspec_junit_formatter/pull/70)

Specifically the comment:

> I think both file and filename are non-standard. Junit is a pretty lean, and isn’t really standardised at all, it’s just what the original junit tool used to produce. But many tools consuming rspec junit formatter output now rely on the file attribute so we cannot remove it now. I’m afraid this might be a problem xunit needs to fix — to ignore unknown attributes, or something.

---

<div class="post-metadata">

**Author:** ![danadaldoss](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/danadaldoss/32/23856_2.png) [@danadaldoss](https://discuss.circleci.com/u/danadaldoss)\
**Post date:** [March 9, 2020, 5:20pm UTC](https://discuss.circleci.com/t/split-by-timings-on-elixir-project-fails-to-find-stored-timings-possibly-missing-file-names-in-junit-xml/34813/2 "2020-03-09T17:20:49Z")

</div>

FOLLOW-UP: The issue is indeed that the `junit-formatter` XML output does not include  
the file name in `<testcase>`s. Local testing of a forked branch has proved that including the file name allows CircleCI CLI to split by timings. I have [opened a PR](https://github.com/victorolinasc/junit-formatter/pull/37) to add a configuration to optionally add the file name to the output.

---

<div class="post-metadata">

**Author:** ![danadaldoss](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/danadaldoss/32/23856_2.png) [@danadaldoss](https://discuss.circleci.com/u/danadaldoss)\
**Post date:** [March 14, 2020, 9:21pm UTC](https://discuss.circleci.com/t/split-by-timings-on-elixir-project-fails-to-find-stored-timings-possibly-missing-file-names-in-junit-xml/34813/3 "2020-03-14T21:21:06Z")

</div>

FOLLOW-UP: I have submitted a documentation PR that explains how to fix the issue now. [https://github.com/circleci/circleci-docs/pull/4225](https://github.com/circleci/circleci-docs/pull/4225)

---

<div class="post-metadata">

**Author:** ![nimrodV81](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/nimrodv81/32/28928_2.png) [@nimrodV81](https://discuss.circleci.com/u/nimrodV81)\
**Post date:** [March 30, 2022, 2:20pm UTC](https://discuss.circleci.com/t/split-by-timings-on-elixir-project-fails-to-find-stored-timings-possibly-missing-file-names-in-junit-xml/34813/4 "2022-03-30T14:20:04Z")

</div>

thank you  
I think specifying the junit family needed for this to work in the docs would be even better

[pytest]  
junit\_family = xunit1
