如何使用 Minitest 进行嵌套测试?
How can you have nested tests with Minitest?
例如,在Jasmine中,您可以这样做:
describe('Person', function () {
describe('movement methods', function () {
it('#run', function () {
});
it('#jump', function () {
});
});
});
使用 Minitest,似乎不能有 "movement methods" 类别。你只需要做:
class PersonTest
def test_run
end
def test_jump
end
end
有没有办法在 Minitest 中嵌套?
是的,你可以。你可以这样做(不是最漂亮的):
class Person < ActiveSupport::TestCase
class MovementMethods < ActiveSupport::TestCase
test "#run" do
# something
end
test "#jump" do
# something
end
end
end
也可以考虑使用 minitest/spec,您可以编写与 Jasmine 代码段更相似的测试用例:
require 'minitest/spec'
describe Person do
describe 'movement methods' do
it '#run' do
# something
end
it '#jump' do
# something
end
end
end
例如,在Jasmine中,您可以这样做:
describe('Person', function () {
describe('movement methods', function () {
it('#run', function () {
});
it('#jump', function () {
});
});
});
使用 Minitest,似乎不能有 "movement methods" 类别。你只需要做:
class PersonTest
def test_run
end
def test_jump
end
end
有没有办法在 Minitest 中嵌套?
是的,你可以。你可以这样做(不是最漂亮的):
class Person < ActiveSupport::TestCase
class MovementMethods < ActiveSupport::TestCase
test "#run" do
# something
end
test "#jump" do
# something
end
end
end
也可以考虑使用 minitest/spec,您可以编写与 Jasmine 代码段更相似的测试用例:
require 'minitest/spec'
describe Person do
describe 'movement methods' do
it '#run' do
# something
end
it '#jump' do
# something
end
end
end