Home Game Development entity part system – How do I write unit assessments in ECS when behaviors trigger creation of deletion of entities?

entity part system – How do I write unit assessments in ECS when behaviors trigger creation of deletion of entities?

0
entity part system – How do I write unit assessments in ECS when behaviors trigger creation of deletion of entities?

[ad_1]

I’m writing a recreation utilizing a customized ECS structure. I not too long ago had a sequence of nasty bugs the place fixing one bug triggered regressions elsewhere. Being a software program engineer by commerce, I suppose that unit assessments would permit me to repair these bugs extra safely (and so sooner) – however the approaches I’d often take to unit testing appear to get snarled within the ECS structure.

For instance:

  • Items are entities (there’s a part which marks an entity as an merchandise)
  • Some entities have inventories, so inventories are parts.
  • Some gadgets can stack when picked up, the place what was two entities on the bottom turns into a single entity representing the stack if each are picked up.

I want to create a take a look at to cowl this stacking habits as a result of I not too long ago had bugs in that space. The situation looks like a fundamental 1+1=2 take a look at: Verify that an empty stock that picks up two an identical stackable gadgets has a stack of two of that merchandise afterward, nonetheless, operating that take a look at requires instantiating the ECS system as a result of this interplay entails creating and deleting entities (the stacked merchandise is a unique entity than both of its constituent gadgets).

Is this situation not such a superb candidate for unit testing in any case, and I ought to write it as an integration take a look at as a substitute? (If so, is it an issue if I discover that just about none of my parts or techniques could be meaningfully unit examined?) Should I reframe my pondering round unit assessments and contemplate a take a look at that covers Component+ECS as a “unit” take a look at? Is the truth that I can not unit take a look at this type of situation proof of a messy code base that I ought to refactor?

[ad_2]

LEAVE A REPLY

Please enter your comment!
Please enter your name here