简体   繁体   中英

Testing executables using rspec

Is there any way i can test a generic executable using rspec? I like the way tests are defined in rspec.

Something along the lines of

it "should return error" do
    program.output.should == "Error in program"
end

Rspec 3.0 output matcher:

expect { its_my_mthd }.to output("its the message for the world").to_stdout expect { its_my_mthd }.to output("its devils message error").to_stderr

Minitest also has something called capture_io:

out, err = capture_io do
  my_method
end

assert_equals "its the message for the world", out
assert_equals "its devils message error", err

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM