For this, I would need to do some unit testing (testing classes and components of the script by themselves) and integration testing (testing the script along with the map and checking that the objects that are retrieved have the expected values or have certain behaviors I want them to have.
For Unit Testing, I can see already some tests with only the classes the script uses, but there's little thing to do a part from verifying a couple of methods and properties. I think for the Hardcore script this is not as important.
For Integration testing, however, there's a lot to be done. Here is a list of things that I would like to check, as en example of assertions:
- That some object has effectively appeared under certain conditions
- That a player has effectively gone to a state I would like him to have (dead, alive, stunned, etc...)
- That some bullets have actually spawned at a certain vector and that they are going in the direction I want them to go
- That a game has effectively started, or ended
- That some points are actually attributed to players when they make a kill
I tried doing a mock of the "IGame" class using the Moq framework like this:
Code: Select all
GameMock = new Mock<IGame>(); GameMock.Setup(m => m.GetSingleObjectByCustomId("IdOfALedgeGrabIObject")).Returns(() => new [what type to use here??] ()());
Also methods like 'Game.CreateObject()', 'Game.PlaySound()' or 'Game.SpawnProjectile()' can't actually be mocked since they directly impact the world map, and from code I don't see how we could assert that they have done their job.
So, that is my question, is it possible to automate integration testing for the scripts in code? Or is the only way to test code to actually run the map and see how stuff behaves, meaning there's no automation viable to be done?