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



12
13
14
# File 'lib/learn_test/strategies/csharp_nunit.rb', line 12

def check_dependencies
  Dependencies::CSharp.new.execute
end

#cleanupObject



48
49
50
# File 'lib/learn_test/strategies/csharp_nunit.rb', line 48

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

#detectObject



8
9
10
# File 'lib/learn_test/strategies/csharp_nunit.rb', line 8

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

#outputObject



25
26
27
# File 'lib/learn_test/strategies/csharp_nunit.rb', line 25

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

#resultsObject



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

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



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

def run
  require 'crack'
  require 'json'

  system("dotnet test")
  output
  cleanup
end

#service_endpointObject



4
5
6
# File 'lib/learn_test/strategies/csharp_nunit.rb', line 4

def service_endpoint
  '/e/flatiron_csharp_nunit'
end