Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to do TDD and unit testing in powershell?
    primarykey
    data
    text
    <p>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 found good methods to unit test power shell scripts? </p> <p>I've found samples of mocking from <a href="http://www.peterprovost.org/blog/post/TDD-with-PowerShell-Mocking-Things.aspx" rel="nofollow noreferrer">Mr Geek Noise</a> - but I'd really like something like <a href="http://ayende.com/projects/rhino-mocks.aspx" rel="nofollow noreferrer">RhinoMocks</a>. <a href="http://blog.brianhartsock.com/2009/03/27/tdd-with-powershell-from-the-client-perspective/" rel="nofollow noreferrer">Brian Hartsock</a> has a sample of running tests on powershell strings from MS Test. A little hacky, but it seems to work. </p> <p>What I want is a Powershell TDD experience that is as clean as it is in "real" languages. </p> <hr> <p><strong>Update to clarify:</strong></p> <p>The first two answers attempt to steer me away from testing Powershell. The opinions are interesting. I don't want to know if it's a good idea to test in powershell. That's a subjective question that should be asked in a different forum. I want a solution to unit testing powershell. If you think it's a bad idea (it might be), treat it as a fun academic question.</p> <ul> <li>Yes, scripting languages glue together disparate systems. However, as already pointed out, it's also easy to mock and break seams in a dynamic language. </li> <li>I'm not asking about "debugging". Debugging is an extremely useful topic. I'll let someone else ask it. </li> <li>Maybe PS scripts should be simple. The language supports modularity and it is inevitable that complex processes will be implemented in PS (even if a bad idea). </li> <li>The answer to this question is not "You can't". I can see (from linked blogs - which are a little old) that some people have made headway on the problem. </li> </ul> <p>To re-state: <strong>How do you implement an automated testing of Powershell logic in the style of xUnit?</strong> Integration tests are interesting, unit tests that break dependencies most interesting. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload