Class: NUnit
- Inherits:
-
Object
- Object
- NUnit
- Defined in:
- lib/nunitr/nunit.rb
Instance Attribute Summary collapse
-
#nuget_nunit_version ⇒ Object
Returns the value of attribute nuget_nunit_version.
-
#nuget_path ⇒ Object
Returns the value of attribute nuget_path.
-
#teamcity_nunit_version ⇒ Object
Returns the value of attribute teamcity_nunit_version.
Instance Method Summary collapse
- #category(name, tags) ⇒ Object
-
#initialize ⇒ NUnit
constructor
A new instance of NUnit.
- #run(pattern, environment = nil, include = nil, exclude = nil) ⇒ Object
- #runner ⇒ Object
Constructor Details
#initialize ⇒ NUnit
7 8 9 10 11 |
# File 'lib/nunitr/nunit.rb', line 7 def initialize() @teamcity_nunit_version = 'v4.0 x86 NUnit-2.5.3' @nuget_nunit_version = '2.6.0.12051' @nuget_path = './.nuget/NuGet.exe' end |
Instance Attribute Details
#nuget_nunit_version ⇒ Object
Returns the value of attribute nuget_nunit_version.
5 6 7 |
# File 'lib/nunitr/nunit.rb', line 5 def nuget_nunit_version @nuget_nunit_version end |
#nuget_path ⇒ Object
Returns the value of attribute nuget_path.
5 6 7 |
# File 'lib/nunitr/nunit.rb', line 5 def nuget_path @nuget_path end |
#teamcity_nunit_version ⇒ Object
Returns the value of attribute teamcity_nunit_version.
5 6 7 |
# File 'lib/nunitr/nunit.rb', line 5 def teamcity_nunit_version @teamcity_nunit_version end |
Instance Method Details
#category(name, tags) ⇒ Object
41 42 43 44 45 46 |
# File 'lib/nunitr/nunit.rb', line 41 def category(name, ) return '' if(.nil? or .empty?) return " /category-#{name}:#{tags.gsub(',', ';')}" if !ENV['teamcity.dotnet.nunitlauncher'].nil? return " /#{name}:#{tags}" end |
#run(pattern, environment = nil, include = nil, exclude = nil) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/nunitr/nunit.rb', line 13 def run(pattern, environment=nil, include=nil, exclude=nil) glob_pattern = "**/[b][i][n]/Release/#{pattern}.dll" dlls = Dir.glob(glob_pattern) raise TestFilesNotFound, "No tests found for pattern #{glob_pattern}" if dlls.empty? if !environment.nil? dlls.each do |dll| config = File.dirname(dll) + "/App.#{environment}.config" raise ConfigFileNotFound, "Config file #{config} not found" if !File.exists?(config) sh "copy #{config} #{dll + '.config'}".gsub('/', '\\') end end includes = category('include', include) excludes = category('exclude', exclude) sh "#{runner} #{dlls.join(' ').strip}#{includes}#{excludes}" end |
#runner ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/nunitr/nunit.rb', line 32 def runner if ENV['teamcity.dotnet.nunitlauncher'].nil? sh "#{@nuget_path} install Nunit.Runners -o ./tools -Version #{@nuget_nunit_version}" return Dir.glob("./tools/*#{@nuget_nunit_version}/**/nunit-console.exe").last end return "#{ENV['teamcity.dotnet.nunitlauncher']} #{@teamcity_nunit_version}" end |