I've been asked to provide a "minimum complete verifiable example" (or MCVE) of my problem. What is that, and how do I provide one?
1 Answer
When asking a question about a problem, especially a problem that involves debugging your code or some behavior of your project, you will get much better answers if you provide steps or code people can use to reproduce the problem on their own. Questions asking about debugging problems are considered off-topic here, unless accompanied by such steps, which should be:
- Minimal – Use as little commands or code as possible that still produces the same problem.
- Complete – Provide all parts needed to reproduce the problem.
- Verifiable – Test the steps or code you're about to provide to make sure it reproduces the problem.
Minimal
The more commands or code there is to go through, the less likely people can find your problem. Streamline your example in one of two ways:
Restart from scratch. Create a new project, adding in only what is needed to see the problem. Make the code short as possible, consisting of only things that will cause your issue to occur.
Divide and conquer. When you have a small amount of code, but the source of the problem is entirely unclear, start removing code a bit at a time until the problem disappears – then add the last part back.
Complete
Make sure all information necessary to reproduce the problem is included:
Some people might be prepared to try your code to test the answer they're about to post.
Provide the actual sample input that you're using. For example, when your problem is related to specific input or data, it's probably a good idea to include the actual data that you're using; the problem might not be in the part you suspect it is, but another part entirely.
Verifiable
To help you solve your problem, others will need to verify that it exists:
Describe the problem. "It doesn't work" is not a problem statement. Tell us what the expected behaviour should be. Tell us what the exact wording of the error message is, and which line of code is producing it. Put a brief summary of the problem in the title of your question.
Ensure that the example actually reproduces the problem! If you inadvertently fixed the problem while composing the example but didn't test it again, you'd want to know that before asking someone else to help.
It might help to transport the example to a fresh machine to confirm it really does provide an example of the problem.
Note: this is a modified version of the Stack Overflow help page of the same name.