Failed Pester Test

Welcome Forums Pester Failed Pester Test

Viewing 3 reply threads
  • Author
    Posts
    • #68280
      Participant
      Topics: 25
      Replies: 43
      Points: 45
      Rank: Member

      Hi Everyone!

      I have a Pester test setup to test out one function within a .psm1 file. The function is very simple and pretty much adds to an existing cmdlet so that the PS code is more clean.

      My Pester Test fails at using the “Add-RabbitMQContent” function noted in code below. If I attempt to pass a local directory or use the $TestDrive\ location it does not work. Any thoughts on why?

    • #68316
      Participant
      Topics: 28
      Replies: 140
      Points: 59
      Rank: Member

      What is the Setup function inside of your test? Also, the reason it’s failing is because you’re writing

      to the file but your test is only checking for

      . Your test should look something like this:

      It’s going to be hard to test to ensure the time was inserted correctly though since it may not be the same second.

    • #68320
      Participant
      Topics: 25
      Replies: 43
      Points: 45
      Rank: Member

      Adam,

      The Setup is not a self-made function. It is a cmdlet to add files to your TestDrive. So I cannot paste URL link in this post but here is code you can find in the Pester project on Github using “Setup.”

      OMG! Such a simple solution. I have been looking at my Pester testing all day. I should have walked away for a bit. I did not catch that. Thank you, Adam. I just this to my test and it worked successfully.

      Thank you,
      -Michael

    • #68322
      Participant
      Topics: 28
      Replies: 140
      Points: 59
      Rank: Member

      It happens to the best of us. :). I was not aware of that setup command. I’ve just always created the file with Add-Content. Learn something new every day.

Viewing 3 reply threads
  • The topic ‘Failed Pester Test’ is closed to new replies.