[
https://issues.apache.org/jira/browse/BUILDR-701?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14080795#comment-14080795
]
Tammo van Lessen commented on BUILDR-701:
-----------------------------------------
Looks like I can neither upload a patch nor edit my last comment. Thus here a
new one:
{code}
>From a60e001c5b2d20fb2e248d6815b04f6c768a723a Mon Sep 17 00:00:00 2001
From: Tammo van Lessen <[email protected]>
Date: Tue, 29 Jul 2014 22:48:52 +0200
Subject: [PATCH] BUILDR-701: add Hamcrest deps for JUnit >= 4.11.
---
lib/buildr/java/tests.rb | 9 +++++----
spec/java/tests_spec.rb | 18 ++++++++++++++++++
2 files changed, 23 insertions(+), 4 deletions(-)
diff --git a/lib/buildr/java/tests.rb b/lib/buildr/java/tests.rb
index 95ef71d..bb83fb6 100644
--- a/lib/buildr/java/tests.rb
+++ b/lib/buildr/java/tests.rb
@@ -96,15 +96,15 @@ module Buildr #:nodoc:
Buildr.settings.build['jmock'] || VERSION
end
- def dependencies
+ def dependencies(versions = {:hamcrest => "1.1"})
two_or_later = version[0,1].to_i >= 2
group = two_or_later ? "org.jmock" : "jmock"
@dependencies ||= ["#{group}:jmock:jar:#{version}"]
if two_or_later
@dependencies <<
"org.jmock:jmock-junit#{Buildr::JUnit.version.to_s[0,1]}:jar:#{version}"
- @dependencies << "org.hamcrest:hamcrest-core:jar:1.1"
- @dependencies << "org.hamcrest:hamcrest-library:jar:1.1"
+ @dependencies <<
"org.hamcrest:hamcrest-core:jar:#{versions[:hamcrest]}"
+ @dependencies <<
"org.hamcrest:hamcrest-library:jar:#{versions[:hamcrest]}"
end
@dependencies
end
@@ -198,7 +198,8 @@ module Buildr #:nodoc:
end
def dependencies
- @dependencies ||= ["junit:junit:jar:#{version}"]+ JMock.dependencies
+ four11_or_newer = version >= "4.11"
+ @dependencies ||= ["junit:junit:jar:#{version}"]+ (four11_or_newer ?
JMock.dependencies({:hamcrest => '1.3'}) : JMock.dependencies)
end
def ant_taskdef #:nodoc:
diff --git a/spec/java/tests_spec.rb b/spec/java/tests_spec.rb
index 5968799..067a301 100644
--- a/spec/java/tests_spec.rb
+++ b/spec/java/tests_spec.rb
@@ -60,6 +60,24 @@ describe Buildr::JUnit do
project('foo').test.dependencies.should
include(artifact("#{group}:jmock:jar:#{JMock.version}"))
end
+ it 'should not include Hamcrest dependencies for JUnit < 4.11' do
+ begin
+ Buildr.settings.build['junit'] = '4.10'
+ define('foo') { test.using :junit }
+ project('foo').test.compile.dependencies.should_not
include(artifact("org.hamcrest:hamcrest-core:jar:1.3"))
+ project('foo').test.dependencies.should_not
include(artifact("org.hamcrest:hamcrest-core:jar:1.3"))
+ ensure
+ Buildr.settings.build['junit'] = nil
+ end
+ end
+
+ it 'should include Hamcrest dependencies for JUnit >= 4.11' do
+ define('foo') { test.using :junit }
+ project('foo').test.compile.dependencies.should
include(artifact("org.hamcrest:hamcrest-core:jar:1.3"))
+ project('foo').test.dependencies.should
include(artifact("org.hamcrest:hamcrest-core:jar:1.3"))
+ end
+
+
it 'should pick JUnit version from junit build settings' do
Buildr::JUnit.instance_eval { @dependencies = nil } # JUnit caches JMock
dependencies
Buildr::JMock.instance_eval { @dependencies = nil }
--
2.0.3
{code}
> update to junit 4.11
> --------------------
>
> Key: BUILDR-701
> URL: https://issues.apache.org/jira/browse/BUILDR-701
> Project: Buildr
> Issue Type: Improvement
> Components: Test frameworks
> Affects Versions: 1.4.19
> Environment: all
> Reporter: Jean-Philippe Caruana
> Assignee: Peter Donald
> Attachments: patch
>
> Original Estimate: 0h
> Remaining Estimate: 0h
>
> buildr comes with an old junit 4.8.2 (april 2010) but a newer version 4.11
> dates from nov 2012.
--
This message was sent by Atlassian JIRA
(v6.2#6252)