unit testing - How can I mock %ENV in Perl tests? -


I retrieve some tests using the test :: more for the legacy code I'm trying and I've bumped in a bit of trouble. I do not think I'm able to set the % ENV in the test module. The I function definitely uses this variable, so < Code>% ENV does not appear in the test object.

  #! / Usr / bin / perl strict; Use warnings; Test :: Use more qw (no_plan); BEGIN {$ ENV} {HTTP_WWW_AUTHENTICATE} = 'WWW-authentication: MyType realm = "MyRealm", userid = "123", password = "ABC"'; Use_ok ('util'); } $ ENV {HTTP_WWW_AUTHENTICATE} = 'WWW-authentication: MyType realm = "MyRealm", userid = "123", password = "ABC"'; Printf qq {get_authentication_info = "% s" \ n}, get_authentication_info (); Ok (get_authentication_info (), 'get authentication information');  

I continue ...

 perl t \ Utilá ok 1 - use; Use the uninitialized value on string on parity (.) Or T \ Util.t line 14. With all the things in Pearl, I'm sure someone has done this before 

Update: Your help Thanks for everyone for

The problem was between the keyboard & amp; Chair ... My test data was just plain wrong

  $ ENV {HTTP_WWW_AUTHENTICATE} = 'MyType realm = "MyRealm", userid = "123", password = "ABC"';  

what

  get_authentication_info ()  

My guess is nothing.

If this is always true, then row 14 will always return "use of the initial value". "Warning."

If you expect the value, why do you need to check that get_authentication_info () is failing?


Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -