使用 Minitest 测试 Grape - 从什么 class 继承?
Testing Grape with Minitest - What class to inherit from?
我的 rails 应用程序正在使用 minitest。我不清楚 class 我应该为我的测试继承什么。我在想 ActionController::TestCase 但这似乎不对,因为它没有附加到 rails 控制器。有什么建议吗?
编辑:
无法使用 MiniTest::Unit::TestCase
,因为它不包含任何测试个人 api 端点的内容。
我没有从特定的 minitest class 继承,而是包含了来自 Rack 的测试助手。
class V0::YourAPI < ActiveSupport::TestCase
include Rack::Test::Methods
def app
Rails.application
end
end
我正在使用 ActionDispatch::IntegrationTest
class
例如:
class ApiRequestTest < ActionDispatch::IntegrationTest
test "sample response" do
get "/api/v1/sample_request"
assert_equal response.success?, true
assert_equal response.code, 200
end
end
我的 rails 应用程序正在使用 minitest。我不清楚 class 我应该为我的测试继承什么。我在想 ActionController::TestCase 但这似乎不对,因为它没有附加到 rails 控制器。有什么建议吗?
编辑:
无法使用 MiniTest::Unit::TestCase
,因为它不包含任何测试个人 api 端点的内容。
我没有从特定的 minitest class 继承,而是包含了来自 Rack 的测试助手。
class V0::YourAPI < ActiveSupport::TestCase
include Rack::Test::Methods
def app
Rails.application
end
end
我正在使用 ActionDispatch::IntegrationTest
class
例如:
class ApiRequestTest < ActionDispatch::IntegrationTest
test "sample response" do
get "/api/v1/sample_request"
assert_equal response.success?, true
assert_equal response.code, 200
end
end