-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature Request] Testing Scaffolding #29
Comments
What we do for krpc1, is write tests for the various endpoints as python scripts, then occasionally (manually) run them with a local copy of the game running. I try and run them when a new version of the game comes out, before a new release of the mod or if some large change is made. (The krpc1 tests have fallen into disrepair recently though and need to be updated...) The tests use a python package called The tests for the krpc1 SpaceCenter service are here: https://github.com/krpc/krpc/tree/main/service/SpaceCenter/test For example, one of the orbit tests looks like this: class TestOrbit(krpctest.TestCase):
@classmethod
def setUpClass(cls):
cls.new_save()
cls.space_center = cls.connect().space_center
...
def test_vessel_orbiting_kerbin(self):
self.set_circular_orbit('Kerbin', 100000)
vessel = self.space_center.active_vessel
orbit = vessel.orbit
self.assertEqual('Kerbin', orbit.body.name)
self.assertAlmostEqual(100000 + 600000, orbit.apoapsis, delta=50)
self.assertAlmostEqual(100000 + 600000, orbit.periapsis, delta=50)
self.assertAlmostEqual(100000, orbit.apoapsis_altitude, delta=50)
self.assertAlmostEqual(100000, orbit.periapsis_altitude, delta=50)
self.assertAlmostEqual(100000 + 600000,
orbit.semi_major_axis, delta=50)
self.assertAlmostEqual(100000 + 600000,
orbit.semi_minor_axis, delta=50)
self.assertAlmostEqual(700000, orbit.radius, delta=50)
self.assertAlmostEqual(2246.1, orbit.speed, delta=1)
self.check_radius_and_speed(vessel, orbit)
# self.check_time_to_apoapsis_and_periapsis(vessel, orbit)
self.assertIsNaN(orbit.time_to_soi_change)
self.assertAlmostEqual(0, orbit.eccentricity, places=1)
self.assertAlmostEqual(0, orbit.inclination, places=1)
# self.assertAlmostEqual(0,
# orbit.longitude_of_ascending_node, places=1)
# self.assertAlmostEqual(0, orbit.argument_of_periapsis, places=1)
# self.assertAlmostEqual(0, orbit.mean_anomaly_at_epoch, places=1)
# self.assertAlmostEqual(0, orbit.epoch, places=1)
# self.check_anomalies(vessel, orbit)
self.assertIsNone(orbit.next_orbit) To get this style of testing working for krpc2 we would need the following:
I can create a bunch of issue to get these various parts implemented. I don't think getting these to run automatically with each PR using github actions is practical:
We could maybe host our own runner with the above requirements, but I'm not sure it's really worth the effort. The testing approach for krpc1 seemed to work well enough for this kind of testing. |
I think unit tests are great. Manually testing these endpoints, but it would be nice to ensure we have reproduciblilty. Not sure how this works with the stripped versions of KSP? I also think there likely has to be a bit more in place to actively do proper testing
The text was updated successfully, but these errors were encountered: