0
lib 디렉토리에있는 클래스에 대한 몇 가지 테스트를 수행하기 위해 사용자 정의 레이크 작업을 작성하려고합니다. 이것은 어떤 모델도 필요로하지 않는 기본 테스트에서 작동하지만 실제로는 일부 모델을 사용하여 테스트해야합니다. 더 고급 레이크 사용법에 대한 나의 첫 번째 진전이고 ConnectionNotEstablished 오류를 얻는 데 방해가되는 다른 장애물들을 거친 후에야 말입니다. 나는 '사용자 지정 TestTask에서 ConnectionNotEstablished 오류가 발생했습니다.
require 'test_helper'
class CityTest < ActiveSupport::TestCase
test "the truth" do
assert City.all.size == 2
end
end
: 여기
require 'rubygems'
require 'app/models/city'
require 'foo'
require 'test/unit'
class SyncTest < Test::Unit::TestCase
@@sync = Foo::Sync.new('test')
def test_cities
assert City.all.size == 2 # the exception is raised at this point
@@sync.cities
assert City.all.size == 102
end
end
실제로 작동하는 단위 테스트입니다 : 여기
Rake::TestTask.new(:test => 'db:test:prepare') do |test|
test.libs << 'test/sync'
test.test_files = Dir['test/sync/*_test.rb']
test.verbose = true
end
가 ConnectionNotEstablished 예외를 발생 시험입니다 : 여기
는 레이크 작업의 내가
ActiveSupport::TestCase
대신에서 테스트 클래스를 파생 시키려고 시도했다.하지만 여전히 ConnectionNotEstablished 오류가 발생합니다. 나는 틀린 일을 분명히하고 있습니다. 누군가가 그것을 발견하거나 더 좋은 방법을 말해 줄 수 있습니까?