How to do TDD and unit testing in powershell?

后端 未结 6 560
遥遥无期
遥遥无期 2020-12-02 08:45

With MS ramming powershell into all new server products, I\'m starting to (reluctantly) think I need to take it seriously. Part of \"taking it seriously\" is TDD. Have you f

6条回答
  •  余生分开走
    2020-12-02 09:24

    PsUnit is now updated with a framework. I had the same problem as you a few months ago and I felt PsUnit was to big and complex for the number of scripts I had to write so I wrote my own unit test framework for PS. PS have the same kind of charectaristics as other script languages likepython for example, i.e. you can override functions anywhere at any time even with scope in the test methods which is great for faking (a.k.a. mocking). That is, if you have a function or object you want to test that depends on other functions you can declare them in your test method to create a local fake implementation.

    So regardles of which test framework you choose to use I'd say PS is very easy to TDD. That was my experience at least.

提交回复
热议问题