Shared contexts and context inclusion possible?

14 views
Skip to first unread message

Hongli Lai

unread,
May 29, 2010, 4:49:12 AM5/29/10
to Igloo-testing
I found igloo-testing today. Very interesting, I didn't know this
syntax is even possible in C++ without using an external preprocessor.
I love how it tries to mimic the syntax of BDD unit testing frameworks
from other languages, like RSpec.

I'm wondering: is it possible to have shared contexts? In RSpec (Ruby)
I can do something like this:

shared_examples_for("a game") do
it("allows multiple players") do
...test code here...
end
end

describe(ANewlyCreatedGame) do
include_shared_example_group("a game")
end

describe(AnAlreadyCreatedGame) do
include_shared_example_group("a game")
end

This allows me test two different classes with a single copy of unit
testing code. Right now I'm using a hack with #include but I'm
wondering whether igloo-testing could come up with something better
and more similar to RSpec's implementation.

Kim Gräsman

unread,
May 29, 2010, 6:11:08 AM5/29/10
to igloo-...@googlegroups.com
Hello,

Thanks for the kind words!

We've experimented with an implementation of Abstract Test Case, where
you build an abstract base context with all the test methods, and then
subclass it into concrete contexts that describe the variation in
Setup.

See igloo's own tests, most specifically abstract_tests.cpp and
sequence_container_tests.cpp, that both use SubContext to reuse test
methods.

Would that help you forward?

Thanks,
- Kim

Kim Gräsman

unread,
May 29, 2010, 6:16:41 AM5/29/10
to igloo-...@googlegroups.com
Oh, and I should probably say...

On Sat, May 29, 2010 at 12:11, Kim Gräsman <kim.g...@gmail.com> wrote:
>
> We've experimented with an implementation of Abstract Test Case, where
> you build an abstract base context with all the test methods, and then
> subclass it into concrete contexts that describe the variation in
> Setup.

... that this is an experiment, and we can't commit to keeping
SubContext or the exact base class construct (ContextProvider<T,
ContextBase>) stable. Maybe something better comes up.

Cheers,
- Kim

Reply all
Reply to author
Forward
0 new messages