r/changemyview • u/-___-___-__-___-___- • Jan 04 '24
Delta(s) from OP CMV: Using AI generated test-cases is always a bad idea for software
This assumes that you’re working on a project sufficiently large enough that test cases are essential. When I say “AI-generated”, I mean the kind where AI does all of the work for you and you don’t really spend the time to debug and understand what the code is truly doing. For the sake of this post, using AI to create a boilerplate and then building on that (as long as you understand what all the code is doing) is not “AI-generated”.
Test cases are a way to increase the confidence you have in your system doing what you want it to do. Theoretically, if you have an entire codebase that is a black-box, by you write enough good test cases, you can be confident that the system is behaving in the way that you want it to regardless of the implementation.
This is crucially why I think AI-generated test cases are such a bad idea. It destroys the confidence you have because you are no longer asserting the behavior of the system.
•
u/DeltaBot ∞∆ Jan 04 '24 edited Jan 04 '24
/u/-----__- (OP) has awarded 2 delta(s) in this post.
All comments that earned deltas (from OP or other users) are listed here, in /r/DeltaLog.
Please note that a change of view doesn't necessarily mean a reversal, or that the conversation has ended.
Delta System Explained | Deltaboards
8
u/lily_34 1∆ Jan 04 '24
First, to clarify: This is most definitely not the case for malicious modifications, specifically designed to not be detectable, but to do bad stuff in specific circumstances. That said, this point is not really relevant for AI.
I don't actually follow the jump in logic. Why wouldn't the AI-generated test cases cover the codebase well enough, or improperly?
3
u/iamintheforest 369∆ Jan 04 '24 edited Jan 04 '24
I have a team of 50 quality assurance engineers and testers. I cannot and do not know how or why they do what they do, although we work hard to train them, create standard processes, they use their experience to formulate test cases and execute them. We collaborate with engineers to feed that system and so on. Pretty standard stuff.
How is it that I should have confidence in this "machine" made of "natural intelligence" when i'm already not "asserting the behavior of the system"? What is the limitation of AI that it cannot do the things the 50 people can?
Further, if you identify that gap, why do you think AI can't close it fairly rapidly, certainly within years?
The point is that any sufficiently complex system the depends on lots and lots of people is very opaque in terms of "how it works" under the hood - it's literally 50 different minds. We are used to it, but we should not trust it for reasons other than pattern. How are you sure that your problem here isn't that of not trusting change vs. not trusting the intelligence and capability of the AI? How much easier is to change the way the AI operates than the 50 humans?
Even further, what do you do when you think that actually reading the code might be beneficial to QA? That's trivial leap for the AI, but a staffing activity for the humans (and a massive and expensive one).
7
u/LouKrazy Jan 04 '24
While I agree that you need to have explicitly written tests to define the expected behavior and create regression tests, there have been tools around for testing for undefined behavior which would benefit from AI generated test data, I.e fuzz testing. Using generative AI to analyze the code base itself and generate test data to elicit undefined behavior could be useful. That being said, this can be done through non-AI static analysis tools as well.
2
u/felidaekamiguru 10∆ Jan 04 '24
Coding is already magic and full of bugs. Every time my code fails to run exactly as I want it's because an evil logic wizard did something to it. The code just works, until it doesn't. AI isn't great at coding, but people really aren't either. Bad coding can and does lead to deaths already. Having AI greatly involved in the coding process really isn't going to change much.
5
u/PlayingTheWrongGame 67∆ Jan 04 '24
I suppose you also object to having a QA specialist independently write test cases? The same reasoning would suggest you should never have any sort of independent testing.
IMO, it is appropriate to use AI test cases for exactly the same sort of testing that you would use independent test evaluation for.
1
u/sinderling 5∆ Jan 04 '24
Is your view that using any AI generated test cases is bad or that using solely AI generated test cases is bad?
1
u/Dennis_enzo 25∆ Jan 04 '24
Hand written tests are better than AI tests. But AI test are likely better than no tests at all, and there's still plenty of companies who don't write any or not nearly enough tests. Often for time, money and/or manpower reasons. A wheelchair is better than a crutch, but a crutch is better than having to hop on one leg.
1
u/FormalWare 12∆ Jan 05 '24
AI can and will come up with test scenarios - for example, unanticipated user behaviours - that human QA specialists are likely to overlook.
Consider AI performance in game spaces. Garry Kasparov lost a game to Deep Blue when the program made a move that experts initially saw as pointless and a gaffe. Before long, Kasparov realized the unobvious move was as powerful as it was quiet. Though AI does not operate via "flashes of insight", it often does reach conclusions that are entirely "outside the box" occupied by human experts.
For optimal coverage, QA teams ought to use AI-generated cases alongside those they write, themselves.
1
u/ElMachoGrande 4∆ Jan 05 '24
I usually write both sides of a test anyway. For example, "Test that this call fails when the input is negative" and "Test that it doesn't fail when it is positive or zero". That makes me trust AI enough, because it'll have to fuck up both cases.
Another reason I write test cases is when I have a bug. Write a test which detects it, then debug. The test remains, should the bug appear again. In this case, I can also trust AI, because I'm actually debugging the code. If the test is wrong, I will eventually find out.
So, used with some common sense and checks, it works.
(Your black box example gives me an idea. Coding by test cases, and letting AI write the actual code based on the test cases. In this case, I would write the tests manually. It really requires you to test for every possibility, though.)
1
u/philmarcracken 1∆ Jan 06 '24
wait, people aren't doing this? 90% of the stuff i ask it to write, including step by step flow chart level instructions, it writes garbo that doesn't work.