Indenting code between test.StartTest and test.stopTest

Issue #612 resolved
Eric Alexander created an issue

I know, get over it right?

Have not found a way to do this:

test.startTest();
      //Code here
      //More Code here
test.stopTest();

Instead it does this (which is harder to read)

test.startTest();
//Code here
//More Code here
test.stopTest();

Is there a way to add an indent to all code between the start and stop test?

Comments (3)

  1. Scott Wells repo owner

    Hah! Technically that doesn't define a lexical scope, so the purist in me is inclined to push back. In fact, what I'd be inclined to say is that you should do the following (and I know many people who do):

    Test.startTest();
    {
        // Do stuff here
    }
    Test.stopTest();
    

    The downside of that is that anything declared in the test block will not be available after the test block, though it's arguable that you can and should query it for test results validation.

    Let me chew on this one. There's no technical hurdle here, but it's just contrary to the typical way that indentation follows lexical scoping.

  2. Eric Alexander reporter

    @RoseSilverSoftware Well nuts. never even thought of doing the {}. Feel free to close this as that will do exactly what I wanted

  3. Log in to comment