testFilter regex not working

https://docs.unity3d.com/Packages/com.unity.test-framework@1.1/manual/reference-command-line.html

I’m having some trouble running tests from command line following these docs. For the most part things are working, but where I’m struggling is that the regex I use for -testFilter doesn’t seem to be completely working as expected and I don’t know why.

My setup is kind of like this: I have a bunch of editmode tests that have two major namespaces, “BattleTests” for those relating to battle-specific scenarios, and “Tests” for things that are more generic (There are more, but I’m focusing on the two for simplicity). So the full names of the tests come out as things like “BattleTests.EnemyHitTest” and “Tests.PressEnterTest” and stuff like that.

Right now what I’m trying to do is run just the tests under the “Tests” namespace, and exclude the ones under anything else including “BattleTests”. So I use “testFilter” with the regex value “^Tests.”. The problem is, for some reason, this still matches to both “BattleTests” and “Tests”. I’ve also tried “\bTests.” and “^\bTests.”. It feels like no matter what I do I can’t get it to ignore characters before “Tests” in the namespace name and treat it like a hard start to the name. If I do “^BattleTests.”, then that filters as expected to just the “BattleTests” namespace. It’s not completely off though, as if I do “^eTests.”, it does not match to “BattleTests”. But if I remove the caret for “eTests.” then it DOES match to “BattleTests” (as one would expect).

Now, I admit that regex is not a strong point for me. But, in my defense, I have taken these into a regex builder, and there I get the results that I expect. I’m not sure what’s going on here, or what I might be missing. I know I could change the name “Tests” to something like “GenericTests” to avoid this kind of confusion, but I’d rather get to the bottom of this. Any ideas from someone more learned on this?

My suggestion is go to a regex tester of some sort…

There are a bajillion on the web, here’s one I found with a quick google (I don’t even use the same one every time, I just grab one will nilly when I need it):

Shove your test strings into the test string section (this would be the potential names of tests).

Stick your regex into the regex and see if it works. Then tweak the regex to your hearts content until it does work systematically for every test.

You can even multi-line all your test strings and then confirm that your regex only selects the lines that you want… for example here I want words that start with D and are followed by only characters:
image

Once you have it working, there’s your regex.

This is a part of the mystery

Can you share the regex, and the source names you’re hoping to match it to?

I see scattered in your post you have several examples, but it’s a lot of noise… break this down into a simple outline for us (meaning you and the rest of us) to review concisely.