2011-10-25 4 views
1

우리는 뭔가 다른 것을 사용할 수 있지만 테스트를 위해 Riot (https://github.com/thumblemonks/riot)를 사용하고 있습니다.Ruby/Rails/Riot에서 프로그래밍 방식으로 테스트 결과에 액세스

나는 테스트 출력과 같이 얻을 : 내가 좋아하는 것

Running a test 
    + something works 
    + something else works 
    - something failed 

> ruby my_test_file.rb

프로그래밍이 정보에 액세스 할 수 있습니다. 다음과 같이 입력하십시오 :

test = TestClass.load("my_test_file.rb") 
result = test.run 
result.errors # some array 

답변

2

내 질문에 답하십시오. 누구든지 관심이 있다면 더 자세한 답변을 게시 할 수 있습니다.

는 다음 평가 시험에서 컨텍스트를 받고 테스트 파일을 평가하고의 요지 : MyReporter이 통과/검사 결과 불합격 처리 구현입니다

Riot.alone! # so Riot doesn't automatically run the tests 

["/path/to/test/file"].each do |test_file| 
    eval(IO.read(path), binding, test_file) # load test file 

    Riot.root_contexts.each do |context| 
    reporter = MyReporter.new 
    context.run reporter 
    # do something cool with reporter results 
    end 

    Riot.root_contexts.clear # clean out root_contexts so it's clean for the next run 
end 

. https://github.com/thumblemonks/riot/blob/master/lib/riot/reporter.rb

을 참조하십시오.