# Is it off-topic to ask for test cases (“use cases”)?

May I ask if you can come up with tests if I have functional code or do I have to develop good tests myself? I did develop a test that works but only with static libraries (which I might consider a bug) but I also want to improve the testcases, which are other programs that can be written in command-line shell language. I want to ask if you know for example what is "expensive" shell command usage so that I can improve the testcases.

• This sounds like a feature request. We don't do those. Did you read the on-topic page? – Mast May 5 '16 at 21:43
• @Mast I don't think asking for test cases is a "feature-request" for code. What feature in your program do you get by simply having automatic tests for it? Automatic tests doesn't add a feature in your application, it just tests the features that are already there. – Simon Forsberg May 6 '16 at 9:07
• What exactly do you mean by "test cases"? – Simon Forsberg May 6 '16 at 9:09
• @SimonForsberg It reads like he wants us to write test cases for him. If that's so, it would definitely be a feature-request. However, it's hard to be sure with how the question is currently phrased. – Mast May 6 '16 at 9:17
• More like asking what is "expensive" usage for a program like mine which in this case is executing other programs. I found good example: strace -cf bash -c 'for i in \$(seq 1 1000); do bash -c ":"; done' then I can make a benchmark and test my speed with that expensive script. So yes, I was looking for an expensive oneliner for a shell. – Niklas Rosencrantz May 6 '16 at 9:33
• @Mast Asking us to write test cases is not a good idea, but asking as to suggest test cases (i.e. describe what things to test) I don't see any problem at all with. – Simon Forsberg May 6 '16 at 9:36
• I found what I was looking for here unix.stackexchange.com/questions/148035/… BUT OpenBSD can't run the test because it won't run static libraries.... – Niklas Rosencrantz May 6 '16 at 9:40
• "Questions [...] asking for advice about code not yet written are off-topic, as the code is not ready for review." – Gareth Rees May 9 '16 at 10:58

According to the Help page, you can ask about the following things:

• Best practices and design pattern usage
• Security issues
• Performance
• Correctness in unanticipated cases

You can ask about your program's "correctness in unanticipated cases", but it's probably too much if you're asking reviewers to write entire "programs ... in command-line shell language".

If you write some tests and include them with your code, I feel sure (and from personal experience) that someone will suggest some tests/cases you may have missed. Here is an example. However, Code Review is not a good place to ask for someone to just give you tests

It's probably better to search for code that does something similar to your code, and look at their tests, there is plenty of open-source code on Github and other places that have test suites.

• Even if you don't include test cases in your code, people might answer with "You need tests! You should test X, Y and Z." – Simon Forsberg May 6 '16 at 9:07
• Yes, that actually happened. I want to learn how to write a test that works both with OpenBSD 5.9 and Linux but OpenBSD won't execute static libraries so I must learn how to link the tests with a dynamic library and that I don't know how to do. I did script a test that I think was quite good and I got a good answer how to improve it. My program was a shell, so I was looking for "usage" that is programming an expensive pipeline for a scripted test that runs expensive shell commands so it was like asking for expensive programs to test my interepreter if it is slow compared to dashor bash. – Niklas Rosencrantz May 6 '16 at 9:36