Friday, September 9, 2022
HomeGame Developmententity element system - How do I write unit exams in ECS...

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


I’m writing a sport utilizing a customized ECS structure. I just lately had a sequence of nasty bugs the place fixing one bug induced regressions elsewhere. Being a software program engineer by commerce, I suppose that unit exams would enable me to repair these bugs extra safely (and so sooner) – however the approaches I might normally take to unit testing appear to get twisted up within the ECS structure.

For instance:

  • Objects are entities (there’s a element which marks an entity as an merchandise)
  • Some entities have inventories, so inventories are parts.
  • Some objects 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 wish to create a take a look at to cowl this stacking conduct as a result of I just lately had bugs in that space. The situation looks like a fundamental 1+1=2 take a look at: Confirm that an empty stock that picks up two similar stackable objects has a stack of two of that merchandise afterward, nevertheless, working that take a look at requires instantiating the ECS system as a result of this interplay includes creating and deleting entities (the stacked merchandise is a special entity than both of its constituent objects).

Is that this situation not such a great candidate for unit testing in any case, and I ought to write it as an integration take a look at as an alternative? (In that case, is it an issue if I discover that just about none of my parts or methods may be meaningfully unit examined?) Ought to I reframe my pondering round unit exams and think about a take a look at that covers Element+ECS as a “unit” take a look at? Is the truth that I am unable to unit take a look at this form of situation proof of a messy code base that I ought to refactor?

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments