Executing specifications via Maven

0 views
Skip to first unread message

Jem Mawson

unread,
Aug 22, 2008, 11:31:50 PM8/22/08
to instinct-general
G'day

How well is Instinct supported by Maven 2?

I note from the example project that specifications are located in src/
spec/java. Do I need to configure maven to compile tests from this
location instead of src/test/java? Or is there an instinct plugin in
the works? Or is there a simpler answer?

I'm a long-time ant user who's skilling-up in maven, so forgive my
question if it seems naive.

The example project pom does not work out-of-the-box, so I'm happy to
roll any fixes I discover back into that file.

Jem

Jem Mawson

unread,
Aug 23, 2008, 1:45:02 AM8/23/08
to instinct-general
Tom, I've since read your blog post
http://adams.id.au/blog/2008/08/deploying-a-maven-artefact-without-a-repository-using-ant/

I regret being another user asking for maven support ... particularly
since I agree with your sentiments on its poor usability. I am using
it so that I can know how to work with it when I have to.

After some searching, an answer seems to be to define the following 2
in the pom:
* add or change /project/build/testSourceDirectory = ${basedir}/src/
spec/java
* add or change /project/build/plugins/plugin for maven-surefire-
plugin to specify the file include pattern. e.g.

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.4.2</version>
<configuration>
<includes><include>**/*.java</include></includes>
</configuration>
</plugin>

I will submit a patch for the example pom.

Cheers
Jem

Tom Adams

unread,
Aug 24, 2008, 8:05:05 PM8/24/08
to instinct...@googlegroups.com
Hey Jem,

Nothing is naive as far as Maven is concerned... :)

Instinct is supported by Maven about as much as I can avoid it (I'm
not drinking the Maven coolaid).

That being said, a lot of people use Maven, some by choice, and would
like to use Instinct. To that end, I've packaged Instinct as a Maven
bundle (though you've found a problem already which is fixed in HEAD).

Instinct *does not* currently have a Maven plugin that would allow you
to run specs from within Maven. Though, you may be able to annotate
them with the JUnit @RunWith(InstinctRunner.class) annotation and pass
them to the standard surefire test runner, I've not tested this
though, you may need to tweak your test dirs as you've mentioned.

Instinct's POM files (both core & example) are also not written to
enable you to build the project using Maven. They're only there to
enable building of a Maven bundle. They were originally written with
the intention of getting Instinct built under Maven, so it may be easy
to get them up and running (the old version will be in the revision
history).

If you'd like to help out with Maven support I'd be very glad to have
you on board, I don't think Maven support is particularly onerous,
it's just that I don't use it, and so don't feel the pain. Even if
you'd like to edit some of the Maven wiki pages to make it easy for
newbies that'd be great.

Cheers,
Tom

--
tom adams | e:tomjadams<at>gmail.com

Jem

unread,
Aug 25, 2008, 12:07:42 AM8/25/08
to instinct...@googlegroups.com
I do have some maven aficionados in close proximity to me. I should be able to lean on them to help out with maven support (corrupting my otherwise innocent mind in the process). Let me see what I can do.




2008/8/25 Tom Adams <tomj...@gmail.com>

Jeremy Mawson

unread,
Aug 28, 2008, 9:29:53 AM8/28/08
to instinct...@googlegroups.com
G'day

I'm interested in implementing spec reporting.

My initial thoughts are that I should derive the report contents from
the ContextResult which is delivered to the ContextRunner after the test
run is complete. But I'm unsure of how the ContextRunner comes into play
when JUnit is being used. As far as I can see, the JUnit 3 & 4 entry
points simply delegate to the SpecificationMethods directly. The
ContextRunner is only used when the TextRunner is the entry point.

Does the ContextRunner get invoked when running under JUnit? Under what
circumstances is the TextRunner used?

Also, what would be the preferred way for the user to indicate they'd
like a report generated?

Finally, would there be a problem with making a template of the RSpec
report format and using velocity on it?

Cheers
Jem


Jem Mawson

unread,
Aug 31, 2008, 6:29:10 AM8/31/08
to instinct-general
OK, ignore what I said below. I have a better handle on things now.

Using the JUnit ant task behaviour as an example I've been extending
the InstinctAntTask to enable a formatter which will write XML to
file. Then I'll implement another ant task to convert the XML to HTML
reports (like the JUnitReport task does).

Cheers
Jem

Tom Adams

unread,
Aug 31, 2008, 7:58:59 PM8/31/08
to instinct...@googlegroups.com
Ah, good, you've figured it out :) Sorry for the delay, busy weekend.

Adding another formatter should do it, I think from memory there's an
enum that will do some of the ant work for you, should be fairly
clear, as there's three formatters already. You should be able to use
more than one formatter

As an approach, consider churning out junit compatible XML, as then
other tools can process it. If you want to write a nicer formatter
(e.g. rspec), you could do this off the XML. That way we're at least
partially interoperable, and other tools can process our XML and use
the formatter.

Tom

--

Reply all
Reply to author
Forward
0 new messages