Avoid running Concordion tests twice in the same test run

91 views
Skip to first unread message

Tim Wright

unread,
Sep 7, 2014, 3:51:02 PM9/7/14
to concord...@googlegroups.com

Hi all,

I was wondering what thoughts everyone has about this idea:

While Concordion is running tests, ensure that each fixture is run at most once.

This would increase the speed of tests when a fixture is being run by multiple concordion:run commands - as well as by jUnit itself.

If it's OK, I'd implement it by creating a singleton run that has a Map of FixtureClass to ResultSummary - and the ConcordionRunner (or some other appropriate class) would look there before executing a fixture - and then put the result in there after executing a test.

Nigel Charman

unread,
Sep 7, 2014, 7:18:32 PM9/7/14
to concord...@googlegroups.com
Hi

I've implemented this before for use with concordion:run, using the runner below.

It's worth experimenting with adding the functionality to ConcordionRunner. That should work for a lot of cases, depending on the fork settings (eg. forkmode in Ant). You'd want to make it threadsafe to support parallel runs.

public class RunOnceRunner extends DefaultConcordionRunner {
 private static Map<Resource,RunnerResult> alreadyRun = new HashMap<Resource,RunnerResult>();

 /**
  * Executes the super <code>execute(Resource, String)<code> method and caches the 
  * results so that, on subsequent invocations, the results are retrieved from the 
  * cache rather than needing to be rerun.
  */
 public RunnerResult execute(Resource resource, String href) throws Exception {
  Resource hrefResource = resource.getParent().getRelativeResource(href);
  RunnerResult result = alreadyRun.get(hrefResource);
  if (result == null){
   result = super.execute(resource, href);
   alreadyRun.put(hrefResource, result);
  }
  return result;   
 }
}


Nigel.
--
You received this message because you are subscribed to the Google Groups "concordion-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to concordion-de...@googlegroups.com.
To post to this group, send email to concord...@googlegroups.com.
Visit this group at http://groups.google.com/group/concordion-dev.
To view this discussion on the web, visit https://groups.google.com/d/msgid/concordion-dev/CAJifTyqLuBqk%3DFTx5T_uGSB4Gw9sbg4H7Jwqk3Wse8jSPtrDFw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Ermac Wins

unread,
Jul 28, 2017, 3:23:27 PM7/28/17
to concordion-dev
Hello, Nigel!

So, I've the issue with multiple invokes of one fixture. That way, I need to decline caching or to do something alike. Hope, you can help me to find a solution.
Best regards.

Nigel Charman

unread,
Jul 29, 2017, 2:17:02 AM7/29/17
to concordion-dev
Hi

As I understand it you have a fixture that you want to be invoked multiple times, but due to the caching mechanism it will only be executed once. Is that correct?

Would you please explain your use case a bit more so we can understand it, and potentially offer alternate solutions?

thanks

Nigel Charman

unread,
Aug 30, 2017, 4:39:19 AM8/30/17
to concordion-dev, Ermac Wins
Hi Ermac

The normal way to do this would be to push the creation of the identity into the fixture class. It may or may not be reflected in the fixture dependent on whether the identity details were pertinent to the example. I assume that they are pertinent to you, given that you are looking at using different identities for test21 and test31.

I don't know what the relevant details of the 2 identities are, but let's say that one has a gold card and the other has a silver card. You might write:

    Given that I have a [Gold](- "#user=createUserWithCardType(#TEXT)") card ...

The method createUserWithCardType() could be a delegate to a UserBuilder class, eg:
User createUserWithCardType(String type) {
    return new UserBuilder().withCard(type).build();
}
Will something like that work for you?

cheers
Nigel

On 28/08/17 7:09 PM, Ermac Wins wrote:
Nigel, hello!
Sorry, i was on holiday last month.

Yes, you've understood the issue correctly.

I have one test (test1.md e.g.) and two more tests (test21.md and test 31.md) that invoke test1.md as first step. test1.md creates some identity.  And test21 and test31 need such identities but that should be different identities for every test.
So i want to disable the caching mechanism or to find another effective solution.

Thank you!

On Sat, Jul 29, 2017 at 2:04 AM, Nigel Charman <nigel.ch...@gmail.com> wrote:
Hi

As I understand it you have a fixture that you want to be invoked multiple times, but due to the caching mechanism it will only be executed once. Is that correct?

Would you please explain your use case a bit more so we can understand it, and potentially offer alternate solutions?

thanks
To unsubscribe from this group and stop receiving emails from it, send an email to concordion-dev+unsubscribe@googlegroups.com.
To post to this group, send email to concordion-dev@googlegroups.com.
Visit this group at https://groups.google.com/group/concordion-dev.
To view this discussion on the web, visit https://groups.google.com/d/msgid/concordion-dev/b803dd9b-0e6e-4cad-986b-b043f5a0f8ed%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages