Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/unit-testing/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby测试:在测试用例中打印_Ruby_Unit Testing - Fatal编程技术网

Ruby测试:在测试用例中打印

Ruby测试:在测试用例中打印,ruby,unit-testing,Ruby,Unit Testing,我是Ruby测试的新手,Google帮不了我 使用Test/Unit,如何打印实例变量,如 test "thing to happen" do do_stuff assert_equal "foo", @variable p @varible end Ruby可以将消息输出到test runner控制台: test "thing to happen" do do_stuff assert_equal "foo", @variable, "@variable is #{@va

我是Ruby测试的新手,Google帮不了我

使用Test/Unit,如何打印实例变量,如

test "thing to happen" do
  do_stuff
  assert_equal "foo", @variable
  p @varible
end
Ruby可以将消息输出到test runner控制台:

test "thing to happen" do
  do_stuff
  assert_equal "foo", @variable, "@variable is #{@variable} when: things to happen"
  p @varible
end

该代码应该将@variable输出到控制台,除非断言失败。您的问题到底是什么?实例变量是在测试用例中还是在被测试对象中?