require File.dirname(__FILE__) + '/../test_helper' require 'test_failure_parser' require 'test_error_entry' class TestFailureParserTest < Test::Unit::TestCase LOG_OUTPUT_WITH_NO_TEST_FAILURE = < expected but was <"abc">. 2) Failure: test_should_fail_two(SubversionLogParserTest) [./test/unit/subversion_log_parser_test.rb:129:in `test_should_fail_two' C:/projects/cruisecontrol.rb/config/../vendor/plugins/mocha/lib/mocha/test_case_adapter.rb:19:in `__send__' C:/projects/cruisecontrol.rb/config/../vendor/plugins/mocha/lib/mocha/test_case_adapter.rb:19:in `run']: <1> expected but was <"abc">. 83 tests, 185 assertions, 2 failures, 0 errors EOF LOG_OUTPUT_WITH_MOCK_TEST_FAILURE = <.force_build_if_requested - expected calls: 1, actual calls: 2 126 tests, 284 assertions, 1 failures, 0 errors EOF LOG_OUTPUT_WITH_TEST_ERRORS = < C:/projects/cruisecontrol.rb/builds/ccrb/work/config/../vendor/rails/actionpack/lib/action_controller/test_process.rb:456:in `method_missing' ./test/unit/test_failure_parser_test.rb:75:in `test_should_fail_due_to_comparing_same_objects_with_different_data' C:/projects/cruisecontrol.rb/builds/ccrb/work/config/../vendor/plugins/mocha/lib/mocha/test_case_adapter.rb:19:in `__send__' C:/projects/cruisecontrol.rb/builds/ccrb/work/config/../vendor/plugins/mocha/lib/mocha/test_case_adapter.rb:19:in `run' 83 tests, 185 assertions, 2 failures, 0 errors EOF def test_should_not_find_test_failures_with_a_build_with_test_errors testFailures = TestFailureParser.new.get_test_failures(LOG_OUTPUT_WITH_TEST_ERRORS) assert_equal 0, testFailures.length end def test_should_find_no_test_failures_with_successful_build testFailures = TestFailureParser.new.get_test_failures(LOG_OUTPUT_WITH_NO_TEST_FAILURE) assert_equal 0, testFailures.length end def test_should_find_test_failures testFailures = TestFailureParser.new.get_test_failures(LOG_OUTPUT_WITH_TEST_FAILURE) assert_equal 2, testFailures.length assert_equal expected_first_test_failure, testFailures[0] assert_equal expected_second_test_failure, testFailures[1] end def test_should_correctly_parse_mocha_test_failures testFailures = TestFailureParser.new.get_test_failures(LOG_OUTPUT_WITH_MOCK_TEST_FAILURE) assert_equal 1, testFailures.length assert_equal expected_mock_test_failure, testFailures[0] end def expected_first_test_failure TestErrorEntry.create_failure("test_should_fail(SubversionLogParserTest)", "<1> expected but was\n<\"abc\">.", "./test/unit/subversion_log_parser_test.rb:125:in `test_should_fail'\n" + " C:/projects/cruisecontrol.rb/config/../vendor/plugins/mocha/lib/mocha/test_case_adapter.rb:19:in `__send__'\n" + " C:/projects/cruisecontrol.rb/config/../vendor/plugins/mocha/lib/mocha/test_case_adapter.rb:19:in `run'") end def expected_second_test_failure TestErrorEntry.create_failure("test_should_fail_two(SubversionLogParserTest)", "<1> expected but was\n<\"abc\">.", "./test/unit/subversion_log_parser_test.rb:129:in `test_should_fail_two'\n" + " C:/projects/cruisecontrol.rb/config/../vendor/plugins/mocha/lib/mocha/test_case_adapter.rb:19:in `__send__'\n" + " C:/projects/cruisecontrol.rb/config/../vendor/plugins/mocha/lib/mocha/test_case_adapter.rb:19:in `run'") end def expected_mock_test_failure TestErrorEntry.create_failure("test_should_check_force_build(PollingSchedulerTest)", "#.force_build_if_requested - expected calls: 1, actual calls: 2", "./test/unit/polling_scheduler_test.rb:44") end end