Cucumber-jvm & Spring Profiles

1,081 views
Skip to first unread message

ZPavel

unread,
Mar 5, 2012, 10:17:21 AM3/5/12
to Cukes
Hi,
I'm trying cucumber-jvm and want to know if the is a way to manage
spring profiles with it?
I mean, in context use:
<beans profile="test">
<bean id="dataSource"
and in the test write:
@RunWith(Cucumber.class)
@Feature("features/model.feature")
@ActiveProfiles("test")
?
Thanks in advance!

Chris Whatley

unread,
Mar 5, 2012, 9:37:07 PM3/5/12
to cu...@googlegroups.com
It appears that this is only going to work right now if you set the property for spring.active.profiles externally (e.g., on the command line).

I think the junit/spring implementation in cucumber-jvm would be a lot more useful if there weren't such an extreme restriction on having methods defined on the junit test class. E.g., I'd like to be able to do what you are asking about as well as maybe some pure-java configuration.

ZPavel

unread,
Mar 6, 2012, 3:55:04 AM3/6/12
to Cukes
Yes, that's what i'm doing using : -Dspring.profiles.active=test
But normally we should use annotations for it.
Did you create a request for this possibility?
Thanks

Miguel Almeida

unread,
Mar 6, 2012, 5:57:15 AM3/6/12
to cu...@googlegroups.com
While I haven't used Spring profiles yet, I actually thought about this problem yesterday.

Right now I have separation of tests using the cucumber tag @inDevelopment: features @inDevelopment aren't finished yet, so they should be run in the developers' machines but not in the continuous integration server or the full test suite.
So, I have a JUnit test InDevelopment_Tests that I filter in maven so it is excluded from maven's test suite and I achieve my goal: test is run in the developers' machines through JUnit but not in the full test suite or the CI server because these tests are run with maven (which excludes that class).

This doesn't solve an increasingly relevant issue: as tests grow, the maven test suite is starting to be not very quick (2-3 minutes). Ideally I'd have another tag, like @stableTests (I'd take it in Spring it would correspond to profile="integration") that would be be excluded in the developer's maven test suite but would be included in the same suite that runs in CI.

Maybe some of this might be useful to you.

Miguel Almeida

Jax Gibb

unread,
Oct 27, 2014, 6:20:00 PM10/27/14
to cu...@googlegroups.com
I am having a similar problem with spring & cucumber. In my case, I'm trying to use 
   @ActiveProfiles(value = "DEV" , inheritProfiles = false)
   @IfProfileValue(name= "ENV" , value = "DEV")
inside my step class,
with a command line of 
   -DENV=DEV
I also tried
-Dspring.active.profiles=DEV

When I run my cuke-test-runner, the steps are always performed, regardless of the combination.
There seem to be very few (if any) people out there trying to do this.

Jax
Reply all
Reply to author
Forward
0 new messages