Sara Bahis
Sara Bahis

Reputation: 71

What's the conventional location for storing stub classes?

I have a system under test and I need to create some stub classes to isolate my SUT. I'm using NetBeans and my question is, should the test classes be saved in the test folder along with the test class or in the main package next to the stubee(?)?

I have heard some creating stubs as inner classes in the test class. I don't want to do that because a lot of my stubs will be shared among multiple classes, so it's better design to make them stand alone and I want to follow the convention of where they're usually stored.

Thanks.

Upvotes: 1

Views: 144

Answers (1)

The111
The111

Reputation: 5867

This is bound to be a topic full of differing opinions, but here's mine:

At the top of your package structure, have a subpackage for all test code. Your mocks/stubs belong in there somewhere. If they are shared between multiple test classes, then a myapp.mytests.shared package seems like a great place for them to go. Otherwise inner classes is also ok.

Upvotes: 1

Related Questions