apex-enterprise-patterns / fflib-apex-mocks

An Apex mocking framework for true unit testing in Salesforce, with Stub API support
BSD 3-Clause "New" or "Revised" License
423 stars 214 forks source link

apex-mocks-generator skips the line after the interface definition #4

Closed adtennant closed 9 years ago

adtennant commented 9 years ago

The title explains it all really, but here are some examples which show how this actually affects things in practice (note the positions of the curly braces):

public interface MyInterface
{
     void foo();
     void bar();
}

Generates:

public class MockMyInterface implements MyInterface
{
    private fflib_ApexMocks mocks;

    public MockMyInterface(fflib_ApexMocks mocks)
    {
        this.mocks = mocks;
    }

    public void foo()
    {
        mocks.mockVoidMethod(this, 'foo', new List<Object> {});
    }

    public void bar()
    {
        mocks.mockVoidMethod(this, 'bar', new List<Object> {});
    }
}

This is correct.


public interface MyInterface {

     void foo();
     void bar();
}

Generates:

public class MockMyInterface implements MyInterface
{
    private fflib_ApexMocks mocks;

    public MockMyInterface(fflib_ApexMocks mocks)
    {
        this.mocks = mocks;
    }

    public void foo()
    {
        mocks.mockVoidMethod(this, 'foo', new List<Object> {});
    }

    public void bar()
    {
        mocks.mockVoidMethod(this, 'bar', new List<Object> {});
    }
}

This is also correct.


However, as soon as I remove that blank line after the method definition:

public interface MyInterface {
     void foo();
     void bar();
}

Generates:

public class MockMyInterface implements MyInterface
{
    private fflib_ApexMocks mocks;

    public MockMyInterface(fflib_ApexMocks mocks)
    {
        this.mocks = mocks;
    }

    public void bar()
    {
        mocks.mockVoidMethod(this, 'bar', new List<Object> {});
    }
}

This is not correct. Notice that foo() has gone missing.

briansieb commented 9 years ago

I have also noticed this issue. Any chance of open sourcing the mock test generator jar? :)

afawcett commented 9 years ago

Yes, i don't see a problem with that, @comic96 would this go in this repo or another?

phardakerffdc commented 9 years ago

I've been wondering about that, I think probably in a separate repo.

phardakerffdc commented 9 years ago

Will work on fixing this as soon as possible!

adtennant commented 9 years ago

Awesome. Guess I can just fix this myself if the generator becomes open source too :)

ImJohnMDaniel commented 9 years ago

@comic96 - This is probably the same issue that I mentioned to you last month. Let me know if I can help.

briansieb commented 9 years ago

Thanks Andy and Paul!

phardakerffdc commented 9 years ago

apex-mocks-generator 3.1.2 released to resolve this issue

john-storey commented 7 years ago

Was the generator made available as an open-source project?

briansieb commented on Mar 16, 2015 I have also noticed this issue. Any chance of open sourcing the mock test generator jar? :)