You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey friends, I have a sorta insane idea I want to run by you. Ive been working on my plugin with CounterStrikeSharp and its great, but I do most of my development on macos, so Ive been organizing my code so that much of it can run outside of the game server environment so i can test it on my mac.
My goal was to make my plugin testable without having to run a server. Both because of my personal environment limitations, but also because I think having plugins be testable in general will make them more reliable and improve the quality of plugins.
So I started playing with the idea of having everything that interacts with a server be wrapped in interfaces that would allow my plugin code to be 95% runnable outside the server, with a default implementation of each interface of course requiring the server. And then separately you could have test implementations to run your logic in a testable environment without the server present.
This PR has a proof of concept of the interfaces and a concrete implementation, but no test implementation yet yonilerner/cs2-retakes-allocator#73. Because I cant force CSS classes to implement my interfaces, I have to rewrap everything. Basically having every class (or at least the big ones like CCSPlayerController to start) implement an interface (eg. ICCSPlayerController) that defines all the methods and fields but would then allow tests to mock any of them (saves all the wrapping hassle).
Here are some key lines of code from my example PR that demonstrates the idea:
This is of course not the only way to make plugins testable, just the one I started playing around with. Before I went further on this work, I wanted to pose to the community: Is there general interest in making plugins (and even CounterStrikeSharp itself) more testable? Is this something that people would find value including in CounterStrikeSharp by default, so that any plugin - and CounterStrikeSharp internals - can be easily tested without having to jump through the hoops I did?
Let me know what you think. Thanks!
The text was updated successfully, but these errors were encountered:
I have a draft PR #331 which auto-generates interfaces for schema classes; though how we can update the core to use these interfaces without breaking backwards compat is up in the air at this point.
Hey friends, I have a sorta insane idea I want to run by you. Ive been working on my plugin with CounterStrikeSharp and its great, but I do most of my development on macos, so Ive been organizing my code so that much of it can run outside of the game server environment so i can test it on my mac.
My goal was to make my plugin testable without having to run a server. Both because of my personal environment limitations, but also because I think having plugins be testable in general will make them more reliable and improve the quality of plugins.
So I started playing with the idea of having everything that interacts with a server be wrapped in interfaces that would allow my plugin code to be 95% runnable outside the server, with a default implementation of each interface of course requiring the server. And then separately you could have test implementations to run your logic in a testable environment without the server present.
This PR has a proof of concept of the interfaces and a concrete implementation, but no test implementation yet yonilerner/cs2-retakes-allocator#73. Because I cant force CSS classes to implement my interfaces, I have to rewrap everything. Basically having every class (or at least the big ones like
CCSPlayerController
to start) implement an interface (eg.ICCSPlayerController
) that defines all the methods and fields but would then allow tests to mock any of them (saves all the wrapping hassle).Here are some key lines of code from my example PR that demonstrates the idea:
This is of course not the only way to make plugins testable, just the one I started playing around with. Before I went further on this work, I wanted to pose to the community: Is there general interest in making plugins (and even CounterStrikeSharp itself) more testable? Is this something that people would find value including in CounterStrikeSharp by default, so that any plugin - and CounterStrikeSharp internals - can be easily tested without having to jump through the hoops I did?
Let me know what you think. Thanks!
The text was updated successfully, but these errors were encountered: