# Circleci tests split with a file

**URL:** <https://discuss.circleci.com/t/circleci-tests-split-with-a-file/42339>\
**Category:** Bug Reports\
**Tags:** circle-yml\
**Created:** [December 21, 2021, 8:20am UTC](https://discuss.circleci.com/t/circleci-tests-split-with-a-file/42339 "2021-12-21T08:20:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![wind57](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/wind57/32/30231_2.png) [@wind57](https://discuss.circleci.com/u/wind57)\
**Post date:** [December 21, 2021, 8:20am UTC](https://discuss.circleci.com/t/circleci-tests-split-with-a-file/42339/1 "2021-12-21T08:20:39Z")

</div>

We are trying to use the splitting feature of circleci. And while some simple use case works just fine, one that is slightly more involved does not, I’ll explain below.

When we do :

```auto
CLASSNAMES=$(circleci tests glob " **/src/test/** /**.java" | grep -v 'spring-cloud-kubernetes-integration-tests' \
                             | xargs grep -l '@Test' \
                             | sed 's/.*src.test.java.//g' | sed 's@/@.@g' \
                             | sed 's/.\{5\}$//' \
                             | circleci tests split --split-by=timings)

```

this works just fine. But this is a trivial case. In our use case the actual tests are computed in various ways with various data, so I can’t pipe the result directly to “circleci tests split --split-by=timings”. That is: we find the tests in multiple operations, and ultimately get an array… I’ve narrowed the problem down to :

```auto
CLASSNAMES=$(circleci tests glob " **/src/test/** /**.java" | grep -v 'spring-cloud-kubernetes-integration-tests' \
                             | xargs grep -l '@Test' \
                             | sed 's/.*src.test.java.//g' | sed 's@/@.@g' \
                             | sed 's/.\{5\}$//')

TEST=$(echo $CLASSNAMES | circleci tests split --split-by=timings)

```

This one fails to discover the tests with : “Error autodetecting timing type, falling back to weighting by name. Autodetect no matching filename or classname.”.

I also found this page : [https://support.circleci.com/hc/en-us/articles/360048786831-Use-test-splitting-with-Python-Django-tests](https://support.circleci.com/hc/en-us/articles/360048786831-Use-test-splitting-with-Python-Django-tests)

where is shows that you can persist the tests to a file and then provide that file to “circleci tests split --split-by=timings”, so we tried that also:

```auto
CLASSNAMES=$(circleci tests glob " **/src/test/** /**.java" | grep -v 'spring-cloud-kubernetes-integration-tests' \
                                           | xargs grep -l '@Test' \
                                           | sed 's/.*src.test.java.//g' | sed 's@/@.@g' \
                                           | sed 's/.\{5\}$//')

echo $CLASSNAMES > tests.txt
TEST=$(circleci tests split --split-by=timings tests.txt)

```

The result is the same error : “Error autodetecting timing type, falling back to weighting by name. Autodetect no matching filename or classname.”.

I don’t get it. This should be trivial to achieve, no? What am I doing wrong here?

Thank you.

---

<div class="post-metadata">

**Author:** ![yannCI](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/yannci/32/24866_2.png) [@yannCI](https://discuss.circleci.com/u/yannCI)\
**Post date:** [January 31, 2022, 11:55pm UTC](https://discuss.circleci.com/t/circleci-tests-split-with-a-file/42339/2 "2022-01-31T23:55:45Z")

</div>

Hi @wind57,

All three examples you shared should indeed yield the same results.

Functionally the `circleci tests split` command takes in a list of strings (like filename or classname), splits them accordingly (by _timing_ or _filesize_ , _etc_ …, whatever you choose), then passes back out the string values isolated to each container.

If you don’t specify a timing type, and if the test splitter is unable to auto-detect it, the it falls back to weighting by filename.

Now if you’d like to pass a list of classnames to the test splitter, you’ll need to specify the `--timings-type=classname` flag.

That said, you’ll need to ensure that:

1. you pass a glob of **classnames** (rather than filenames).
2. classnames in said glob **exactly** match the corresponding strings displayed in the `classname` field of the tests results.

One way to troubleshoot this is to `echo` the list of classnames produced.

Let me know if this helps.
