5

In our product, we're implementing something like - "video asset name is not allowed with special characters".

There are many special characters. In order to test or automate this, if I try to create a video name with every special character like:

  1. Vid-eo
  2. Vid~eo
  3. Vid#eo

etc.

There will be a large number of tests and it will take a lot of execution time. Is there any efficient way to test this? Can we extract 2-3 test cases to adequately test prevention of names with special characters?

2

7 Answers 7

3

As there are to many characters to test them all. You need to think about how many cases you need to safe-guard.

I think only two cases are needed to document the behavior

  • one with special characters
  • one without special characters

I would try a couple different characters and combinations when doing exploratory testing sessions, but not create test-scripts for a lot of cases. It possible to add more cases in the future if they are found to be giving problems.

Second I would also look at the actual code. I would presume a regular expression is used. Verify that it is correct. Verify that it has positive and negative unit-tests. If it has tests I would wonder if you need a test-script to safeguard it.

If you do want to test all cases, create a list and loop your test with the cases. I like this list: https://github.com/minimaxir/big-list-of-naughty-strings

Other questions I would ask are:

  • What is a special character? ~!@#$%^&*()-_=+[]\{}|;':",./<>? + ` or also UTF-8 characters like chinees: 漢字
  • How about numbers? 1234567890
  • Why are they not allowed? Just handle them correctly everywhere, make your application uni-code compliant.
  • Just include any problematic characters to an exclude list, can we make the test list much shorter?
1

If you use black-list tests, you will need a number of test cases, e.g. you need to test a name against a known list of special characters, if there is a match, test fails.

How about go with a white-list approach, e.g. you test every single character, if this character is an alphabetical char? If every character is an alphabetical char, test success.

1
  • 1
    That's not the right solution. Whilst you should test that valid characters are accepted, the requester still needs to check invalid characters aren't accepted. Oct 7, 2016 at 22:39
1

@Agree to Yu. I will use following approach:

  • We have text

    1. If its with special characters we can verify :

text.contains("special_char_which_you_wanted_to_chk")

  1. When above case 1 failed - Means your string doesn't contains special characters

Note - You need to verify all special characters in loop if more in numbers

1

Why don't you try using regular expression.

So, Sample regular expression can be:

([v,i,d,e,o,V,I,D,E,O])\w+

One regular expression should identify all combinations.

P.S: Regular expression given about is not really accurate. But as per answer to your question. Regular expression is batter way to handle this.

1

Background:

We typically call this type of testing (or technique) equivalence class or equivalence class partitioning. In a nutshell equivalence class partitioning means certain groups of input or stored data are treated the same by the program.

We can break these equivalent values into groups and select a few from each group to test with. Each test is powerful in that it might reveal a failure for the whole group and because of this we only need to run a few tests to prove a failure is possible.

For example some applications might treat special characters the same regardless of if they are @, !, #, $, etc. You need to figure out how your application treats these things.

Your Problem:

In order to apply this to your problem of a 'name without special characters' you need to do some research. I'm assuming this is an application with a name input field, correct? Ask yourself:

  • What data type is the input field? Is it a string, text, or other type field? Data Types typically have common failure points.
  • Is there validation used on the input field?
  • Where is this name field stored?
  • Where is this name field used elsewhere in the application?
    • If you enter a special character into an input field name and it isn't filtered out, does it break the name field used somewhere else?

When you start to understand these questions you can start to ask yourself / test to understand if the application treats one special character like $ equivalent to ? or & or (), etc.

0

I assume your talking about the test cases you need to actually test this.

You could just create an array with invalid characters and either choose randomly or iterate depending on the day of the week/month. This way you would be able to with sufficient confidence say that the software is not accepting these invalid characters.

0

The set of special characters is limited and mostly about a few key characters.

So you could do something like this (in ruby):

special_chrs = "?<>',?[]}{=-)(*&^%$#`~{}"
regex = /[#{special_chrs.gsub(/./){|char| "\\#{char}"}}]/

You can then use the regex to test if a given string contains a special character:

if the_string_being_tested =~ regex

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.