UTT: AssertionComponent won't mark test as successful if it checks a value from another gameobject

Not sure if that's the right forum, but as far as I know Unity Test Tools is made by Unity team.

I recently started to experiment with UTT and stumbled across a problem that I can't solve:
When I create AssertionComponent from code (using IntegrationTest annotations) and check some value of the component that isn't attached to the same GameObject as AssertionComponent, it won't return "Success" to the Integration Test Runner and will simply timeout itself.

It does perform check as far as I can tell, since it will throw an assert exception and mark test as "Failed" if conditions of the assert weren't met.

Here's some modified example code from the UTT package to help me illustrate the issue:

Most likely I'm missing something but for now such behavior is odd to me.


When the test starts, it will get all the assertion components on the test game object:

Note that the assertion components are on the test game object (the one with the TestComponent on it), you are adding the assertion component to the test object in your scene.

1 Like

Yes, that’s what I did.

So I run a debugger (it didn’t work for me previously for some reason), and what I found out is that on CreateAssertionComponent method, AsserionComponent will be created on the gameObject that is passed as the parameter.

There is an overload of the method that would take two gameobjects as parameters, but it would use second one only for comparison.

I guess I’ll have to create an overload like this?

private static T CreateAssertionComponent(out IAssertionComponentConfigurator configurator, CheckMethod checkOnMethods, GameObject originObject, GameObject gameObject, string propertyPath) where T : ActionBase

var ac = originObject.AddComponent();

Am I right?

These methods are just helpers.. you can create something on your own that will do the comparison.

1 Like

Sure, I just wanted to use the utilities provided by the unity team.

Anyhow, I created overloads for Create and CreateAssertionComponent that take additional GameObject parameter (reference to gameObject with TestComponent on it) and now everything seems to work. Thanks.

1 Like