12

I want to test the components of my app in isolation from each other. I know, it sounds obvious--maybe I'm asking the wrong questions.

Say I have a component "A" and a component "B". When I build my whole app, I need both components in full, naturally. But when I test "A", I don't want it to require anything from "B". I want to be able to run an "A" test that needs nothing from the other components--I don't want to build the whole app. In fact, I want to exclude certain components so I can use mockups instead.

It seems obvious, but I can't find anyone who talks about how to do this. I've cobbled something together, but it's clunky as hell. I've done quite a bit of research on the matter--I won't bore you with it here. I'm just wondering whether it's ok to post this kind of question on SO, and whether anyone has any tips for making it a more effective question. If it's not okay here, which SE site would be better?

2 Answers 2

6

I don't disagree with Makoto's answer suggesting Software Engineering.SE. Your core concern seems to be component design, which is more "whiteboard" than "keyboard". But I am maybe getting a different impression than Makoto did from your description. I think your question would be just fine here: it sounds like you've already got code (and an IDE) that you're working with. A question about rewriting your implementation and/or configuring your tool to accomplish a specific goal should be perfectly acceptable here.

That said, however: you might have an easier time on Software Engineering. Stack Overflow is -- unfortunately -- leaning hard towards "my code is broken" questions these days. You might get some people finding your question too broad or vague, and/or pointing you towards Code Review. (Your question also might linger for a day or two before somebody gets the time to compose a good answer.)

This is why I highlighted "specific" above. You need to be as concrete as you possibly can about where you are and where you want to go. Provide the important parts of the code, describe the structure, explain the problem that it's causing. This holds true on any SE site, but especially on SO.

Long story short, I think this could fit on either SE.SE or SO. Personally, I look forward to seeing questions like this.

4
  • 2
    "leaning hard towards 'my code is broken' questions these days" Of course, the only way out of that is for other kinds of questions to actually be posted...
    – jscs
    Commented Jan 27, 2019 at 20:46
  • 5
    I recommended Software Engineering because I'm not convinced many of us here would have the patience to actually answer the OP or give the question a moment's reprieve before it was closed. I'd like to see a question like this here too, but I'm just not convinced it could survive long enough for me to see it.
    – Makoto
    Commented Jan 28, 2019 at 4:50
  • 1
    @JoshCaswell Other kinds of questions get downvoted, example with 3 downvotes, zero comments.
    – Cœur
    Commented Jan 28, 2019 at 7:08
  • 1
    Indeed, that's a disappointing example, @Cœur.
    – jscs
    Commented Jan 28, 2019 at 15:47
5

Since you seem like the sort of person who does their research before asking a question (thanks!), the kind of question you're asking sounds like it'd be a better fit on Software Engineering as opposed to here.

Take this advice with a grain of salt, though:

  • Don't post the hard code; you seem to want to describe the problem at a whiteboard so search for similar questions to your own on the site first, and if you can't find something which satisfies, then make a new question, citing the ones you've looked at.
  • Don't lean on the implementation of it; you want to learn the mechanics, not the code.
  • Don't be surprised if you don't get a reply for a while. All of the other sites in the network are orders of magnitude smaller than Stack Overflow and don't have nearly as much click traffic going to them.
  • Peruse the Help Center to be sure that your question aligns with the site's goals. I cannot stress this one enough.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .