What for of testing should i have applied to this data question?

I recently had this question and was unsure how to answer for some testcases
what sort of logic should i have followed ?

3 Likes

Firstly, hello and welcome!

It depends on the secret desires of the person who posed the question. This isn’t a question you will get in real life. Nobody has ever come up against this sort of problem and it will not impact the life of anyone, so it’s more about what they think they’re trying to test for - which you could predict or ask, I suppose. However, I’ll tell you my thought process as someone who has tested software against descriptions before.

How I might answer this question
My first question is who are you and why do you want to know? Any approach I might take will change based on context, which defines the value of what I might do. Perhaps this actually doesn’t need much testing because it’s in a free game I’m throwing on itch.io for fun, or perhaps it needs to meet rigorous standards as it’s part of a military safety system. I can’t know without more information about what’s going on.

Next I need to know what problem this is actually solving. The problem with the question is that it doesn’t solve a problem, and often in real life the description of how a problem might be solved and how it’s actually solved are different. I would have to test the question as well as the product itself. The description of the problem is also necessarily a partial model of any realistic solution, so I would have to test for everything the question does not specify. For example what programming language is this in and on what platform does it run? With what does it interact? And so on. If you think that doesn’t matter then look at the statement “input strings can be any length” and ask what happens when I push a 100TB text file into your Python code on your computer with a 10GB hard drive.

I want to see the code. If I can look inside then I can get some idea of what it trying to do in a realistic way without relying on the pontificating in the question. This will inspire a lot more testing ideas and inform me about the weaknesses in the question.

Okay, so let’s take a deeper look at the question.

A. A service processes a collection of string values and returns a collection of processed strings.

Okay. I’d like to know what the strings are, can be, are likely to be, might be and so on because that helps me to understand what’s likely and what’s possible. What if someone who wanted to break it could control the input? Or is this downstream from a system that we’ve tested carefully to reject certain inputs?

B. The input strings may be any length and can contain any character

Not true, surely. Any length ever? What system would be able to deal with the largest strings the world has ever seen? So it’s obviously silly - therefore it’s worth testing what lengths it can handle, or it’s worth making very sure that we sanitise the inputs so that we can reject very extreme data and better predict what we need to handle elsewhere.

Also I assume this is any Unicode character. There are lots of characters in the world that are not represented by computers, generally, in a way that we can process them in most programming languages. We might have to translate Klingon to some encoding so that we can process it then translate it back to Klingon, or whatever. How is this handled? Or is it actually more likely that we’re limited to letters, numbers and “special characters” found on most keyboards. Again, what’s the limitation of the upstream output, or what can we assume a hacker or vandal might do with crazy inputs?

C. Output strings must not be null or an empty string, 
D. should be truncated to a max length of 15 chars
E. contiguous duplicate characters in the same case should be reduce to a single character in the same case
F. Dollar sign ($) should be replaced with a pound sign(ÂŁ)
G. and underscores and number 4 should be removed
H. The returned collection must not be null.

I don’t know why it’s doing any of this, but okay.

Let’s pretend it’s a black box where I can feed in inputs and it vomits outputs. The inputs are a single string and the outputs are a “collection” (whatever that means) of strings.

Big Problem: We don’t know what inputs will result in what outputs, so we cannot reliably form good coverage. Without being able to create the states necessary to, say, process a dollar sign into a pound sign, how do we test that it’s doing that okay?

So let’s pretend instead that this is the pseudocode for the program, as the order described in the question:
1. Accept Unicode input string of up to 10,000 characters
2. Truncate to 15 characters
3. Replace contiguous character strings of one character with single copies of that character
4. Replace all $ with ÂŁ
5. Remove _ and 4 characters
6. Return the string

I didn’t include point H because it wouldn’t be obvious that the result could ever be null. I don’t know why null is such a bad thing, so I don’t know why I should test for it.

The first thing to note is that empty strings are possible here. Input the number 4 and the result will be empty. Okay, now what? What should the program do when the output is empty? Remember that empty outputs are not allowed, but here they are explicitly possible.

The second thing to notice is that is says to truncate to max 15 characters, but this particular order of operations means that we can have far fewer than 15 characters. It also means that we might miss characters beyond the 15th character that were in the original string…

Case Input Output
Truncate first __15charshere**444XXX 15charshere**
Truncate at the end __15charshere**444XXX 15charshere**XX

You see? The order we do things in matters. And this means that the description of the problem has some weirdness to it, because both outputs are truncated and they are “max 15 characters” but they’re different for the same output. We could clear this up by looking at the actual program, of course, to decide what realistically will or could happen. And if I can make something particularly fun happen with a little creativity.

I hope I’ve proven that the description of the service in the question and the rules they provided don’t really match up, but here are some things we could test for with regards to only looking at functional capability. I’ll follow up with some examples of test case format things you might want to try, just for completeness.

2 Likes

This looks like an ISTQB or other kind of test question, fabricated criteria, and probably a dozen possible ways to ensure the examinee does boundary analysis might be all that they are after, the other rules are perhaps just to add meat to the question. There is so much stuff in there, unicode strings, what do we mean by “null” and even length of strings allowed along with total collection size limits, so merely proving you have a thinking head will probably narrow it down and give you some marks.

Oh, and welcome to the community.

2 Likes

Here’s some other things you might do (continued from above)

Rule Description Input Output
C What does a null output do? “” Some kind of error?
D Try exactly 15 for boundary reasons x3x5x7x9x12x15x x3x5x7x9x12x15x
D Try over 16 to see if it’s truncated x3x5x7x10x13x16x x3x5x7x10x13x16
E Contiguous removal at start of string AAABC ABC
E …middle of string… ABBBC ABC
E …end of string. ABCCC ABC
E Various separators* AA_AA.AA AA4AA AA. AA
E Reduction to empty string 444 Some kind of error?
F OFAT functional test for sanity $ ÂŁ
F Downstream from D _$… ££££££££££££££
F Downstream from E $ ÂŁ
G To empty _4 Some kind of error?
G Sanity / start 4A_ A
G middle ABC_ABC ABCABC
G end ABCABC_ ABCABC

*This is an interesting case. What kind of separators are there? And it’s also another example of ordering the rules because if the underscores were removed before the contiguous letters were then the results would be different. We could do all kinds of testing here!

There’s so, so much more. I haven’t even covered the basics. We can combine all of the rules and see if they play nicely together. And this is only testing the capability of the functionality of a described system, imagine what the real one might be like. And I hope that these examples give you some insight into others that might be possible.

Consider other examples to test each rule. What could we do that isn’t mostly covered in something I’ve written?

Try considering some possible risks. What could go wrong? What input can we provide to test that?

Also consider that some risks you won’t think of. What kind of inputs might we provide to create some coverage of those events?

Edit: I found a bug with the spreadsheet editor. I can’t paste in asterisks or it marks it as italics, and I can’t paste in “_$$$$$$$$$$$$$$$” because it truncates it for some reason. This is the string that should be in the 2nd F row, incidentally. It isn’t that it’s 16 chars long, because my counterstring in the 2nd D row is the same length.

Thanks for the feedback.

I was thinking i had forgotten some old itsqb test case scenario… but looks like nor, and yes it is pretty open to interpration !

2 Likes

Most welcome.

I know that I didn’t give you a neat exam answer, but honestly the real world is nothing like this question. Not just because reality involves unwritten requirements and the written requirements, intended design and actual software never match each other, but because the question doesn’t explain itself properly and leaves all these vital gaps. Not only does the answer to this question not matter it is literally impossible to provide a knowingly correct answer. If I got this task in a company (although I wouldn’t work in places that use test cases) I’d take it to the author and demand an explanation.

There just aren’t a list of logical rules we can apply to turn descriptions into testing, it’s far more open-ended and murky and dynamically shifting. Still, I suppose that’s what makes it an engaging job.

2 Likes