#Unit Testing in ECS

1 messages · Page 1 of 1 (latest)

lilac viper
#

I would like to create my “Character” Entity in my Test Environment.

How can I make sure that the “Character” I create in my Test Environment has always the same Components as the original “Character” from the Baker?

Normally I would use the Factory Pattern or try some kind of Dependency Injection, but I can't think of a way how to accomplish this with ECS. The only way I can currently think of is to copy the Code from the Baker into the Create function in my Test Environment, but this definitely doesn’t look clean to me.

If I just copy the code, then I would often have to go back to my Tests and change how the “Character” is being created after changing anything in my Baker, which defeats the whole point of automatic testing a little bit...

Did anyone face a similar dilemma before?

gloomy valve
#

why not just bake it?

lilac viper
#

do you mean calling the bake process from the Test Environment?

gloomy valve
#

yeah, I can't remember the API though

#

but it supports to bake specific prefab

lilac viper
#

ohhh yeah that was another option I had in mind