Class: LearnTest::Strategies::CSharpNunit

Inherits:
LearnTest::Strategy show all
Defined in:
lib/learn_test/strategies/csharp_nunit.rb

Instance Attribute Summary

Attributes inherited from LearnTest::Strategy

#options, #runner

Instance Method Summary collapse

Methods inherited from LearnTest::Strategy

#argv, #configure, #die, #initialize, #learn_oauth_token, #push_results?, #run_install, #user_id, #username

Constructor Details

This class inherits a constructor from LearnTest::Strategy

Instance Method Details

#check_dependenciesObject



14
15
16
# File 'lib/learn_test/strategies/csharp_nunit.rb', line 14

def check_dependencies
  Dependencies::CSharp.new.execute
end

#cleanupObject



50
51
52
# File 'lib/learn_test/strategies/csharp_nunit.rb', line 50

def cleanup
  FileUtils.rm('TestResult.xml') if File.exist?('TestResult.xml')
end

#detectObject



10
11
12
# File 'lib/learn_test/strategies/csharp_nunit.rb', line 10

def detect
  runner.files.any? { |f| f.match(/project.json/) }
end

#outputObject



27
28
29
# File 'lib/learn_test/strategies/csharp_nunit.rb', line 27

def output
  @output ||= Crack::XML.parse(File.read('TestResult.xml'))
end

#resultsObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/learn_test/strategies/csharp_nunit.rb', line 31

def results
  {
    username: username,
    github_user_id: user_id,
    repo_name: runner.repo,
    build: {
      test_suite: [{
        framework: 'nunit',
        formatted_output: output.to_json,
        duration: output['test_run']['duration']
      }]
    },
    examples: output['test_run']['total'],
    passing_count: output['test_run']['passed'],
    pending_count: output['test_run']['skipped'],
    failure_count: output['test_run']['failed'],
  }
end

#runObject



18
19
20
21
22
23
24
25
# File 'lib/learn_test/strategies/csharp_nunit.rb', line 18

def run
  require 'crack'
  require 'json'

  system('dotnet test')
  output
  cleanup
end

#service_endpointObject



6
7
8
# File 'lib/learn_test/strategies/csharp_nunit.rb', line 6

def service_endpoint
  '/e/flatiron_csharp_nunit'
end