Class: Course::Assessment::Java::JavaProgrammingTestCaseReport

Inherits:
ProgrammingTestCaseReport
  • Object
show all
Defined in:
lib/autoload/course/assessment/java/java_programming_test_case_report.rb

Overview

Represents a Java Programming Question test report.

Due to JUnit lacking the features to append meta data onto testcases, Java evaluation uses TestNG go get around this. This is used to parse TestNG's xml report.

Defined Under Namespace

Classes: TestCase, TestSuite

Instance Method Summary collapse

Constructor Details

#initialize(report) ⇒ JavaProgrammingTestCaseReport

Parses a test case report.

Parameters:

  • report (String)

    The report XML to parse.


226
227
228
# File 'lib/autoload/course/assessment/java/java_programming_test_case_report.rb', line 226

def initialize(report)
  @report = Nokogiri::XML::Document.parse(report)
end

Instance Method Details

#test_casesEnumerable<Course::Assessment::JavaProgrammingTestCaseReport::TestCase>

Gets the set of test cases in this report.

Returns:

  • (Enumerable<Course::Assessment::JavaProgrammingTestCaseReport::TestCase>)

242
243
244
# File 'lib/autoload/course/assessment/java/java_programming_test_case_report.rb', line 242

def test_cases
  test_suites.map(&:test_cases).tap(&:flatten!).select { |test_case| valid_test_method(test_case) }
end

#test_suitesEnumerable<Course::Assessment::JavaProgrammingTestCaseReport::TestSuite>

Gets the set of test suites found in this report.

Returns:

  • (Enumerable<Course::Assessment::JavaProgrammingTestCaseReport::TestSuite>)

233
234
235
236
237
# File 'lib/autoload/course/assessment/java/java_programming_test_case_report.rb', line 233

def test_suites
  @report.search('./testng-results/suite').map do |suite|
    TestSuite.new(suite)
  end
end