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?