How to do TDD and unit testing in powershell?

后端 未结 6 554
遥遥无期
遥遥无期 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

    From your question I think you are headed for disappointment. Powershell is just a little command line language. Sure, it can do anything that C# can do, and even more, but then so can assembly language. Of course it's also OO and hooked in to the .NET libraries, but so is C#, which is a much much cleaner language.

    If a solution is longer than a one liner, or you think you need to TDD it, then you don't want to be using Powershell. It's a cryptic language that is full of surprises, to be avoided for anything complicated.

    If you want to do some ad hoc search and replace or formatting of text, or look around in your file system, then Powershell is your friend. What you really want to do is to use it a little every day, and repeat yourself often, in order to stay familiar with the syntax. For this reason, also avoid open source Powershell libraries, and forget about writing your own CmdLets, unless you have a very specialized case for ad hoc command line usage. The pipe binding rules are arcane and ugly.

    This is all just my opinion of course, but I am a long time Powershell user and am much happier with it now that I look at it like this.

提交回复
热议问题