3

How do I share a fixture between my cucumber and jasmine test?

I can create a fixture with one jasmine server integration test that can be used with other jasmine server integration tests. But (due to different "mirrors" I guess?) I cannot use the same fixture in a cucumber test. The Mongo collection does not have the data created by the jasmine server integration tests.

One option is to save the state to a flat file, or nock, something similar outside of meteor. But, it would be a lot simpler to reference a common collection (on the same mirror?) for test fixtures. Is this possible?

Nathan Buesgens
  • 1,415
  • 1
  • 15
  • 29

3 Answers3

1

You can use the package-fixture pattern for fixtures to achieve what you're asking for. See here: https://github.com/meteor-velocity/velocity#fixtures--test-data

Any packages that you create with the debugOnly flag in the package descriptor will not be bundled in production.

Xolv.io
  • 2,483
  • 1
  • 15
  • 17
  • Thanks for responding. I like the book. I'm actually using a package for my test fixture but the collection data that is in my fixture in jasmine is different than the collection data that is in my fixture in cucumber. I can try to produce an example if this is not the expected behavior. My integration tests produce fixture data as a side effect and I want to use that data in cucumber. – Nathan Buesgens May 04 '15 at 13:32
  • I would recommend that you extract the logic that produces data out of being a side-effect and into the package so you can control it. Another consideration is that frameworks run in parallel. So the data produced in the jamine test run cannot be "piped" to be used in cucumber. You could create a data baseline after the integration tests have run (maybe dump into a file) but honestly I would look at extracting the data creation into an isolated bit of code so you can have separation of concerns and therefore maintainability – Xolv.io May 04 '15 at 16:25
0

Everything is possible. However, I do not recommend to make tests depend on each other. As Wikipedia states:

Ideally, each test case is independent from the others.

A few reasons why your tests should be independent:

  • Easier to narrow down the problem if tests fail (if tests depend on each other you will have some test failures, where simply the predecessor did fail)
  • Allows for parallelisation to reduce total test run time (as your test suite grows)

Currently Velocity hard-codes port 5000 for the test mirror instance of your app, but I know that there are efforts to make this port configurable (which would have to be supported by the test frameworks themselves).

Peter Ilfrich
  • 3,727
  • 3
  • 31
  • 35
  • I don't want tests that depend on each other, and I'm not writing unit tests. I want an integration test and an end to end / acceptance test that both depend on the same test fixture. – Nathan Buesgens May 04 '15 at 01:58
  • Velocity no longer hard codes ports to be 5000 for mirrors, it uses freeport now and all frameworks have been upgraded. You should update to latest :) – Xolv.io May 04 '15 at 02:48
0

The summary answer to this is: shared runtime state between test tools is not supported usage (although both can execute code from the same fixture package). The usage I am going for is not a conventional pattern and involves some sort of dependency between tests.

To get what I was going for I had to write my own tool. What I wanted was basically a wrapper around nock to help me generate test fixtures by recording the results of my e2e tests with integrations turned on.

Nathan Buesgens
  • 1,415
  • 1
  • 15
  • 29
  • I created package that can do this. It's called http-interceptor but it's but fully documented yet. github.com/xolvio/http-interceptor – Xolv.io May 06 '15 at 16:09