Unit testing with network-reliant code

后端 未结 3 1291
陌清茗
陌清茗 2021-02-06 00:53

I\'m trying to be better about unit testing my code, but right now I\'m writing a lot of code that deals with remote systems. SNMP, WMI, that sort of thing. With most classes

3条回答
  •  爱一瞬间的悲伤
    2021-02-06 01:20

    The easiest way to test things which are hard to mock is to refactor the code in the way that your code (logic which is worth testing) is in one place and other things which your code use are in separate module(s). The module is easy to mock and this way you can focus on your business logic.

提交回复
热议问题