0
0
Testing Fundamentalstesting~20 mins

Data validation rules in Testing Fundamentals - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Data Validation Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding Data Validation Purpose

Why is data validation important in software testing?

ATo check that input data meets required formats and rules before processing
BTo ensure the software accepts all types of data without restrictions
CTo speed up the software by skipping input checks
DTo allow users to enter any data to test software flexibility
Attempts:
2 left
💡 Hint

Think about what happens if wrong data is processed by software.

Predict Output
intermediate
2:00remaining
Output of Validation Function

What is the output of this Python validation function when input is 'abc123'?

Testing Fundamentals
def is_alphanumeric(s):
    return s.isalnum()

result = is_alphanumeric('abc123')
print(result)
ANone
BFalse
CTrue
DSyntaxError
Attempts:
2 left
💡 Hint

Check what isalnum() returns for letters and numbers combined.

assertion
advanced
2:00remaining
Correct Assertion for Email Validation

Which assertion correctly tests that the email validation function rejects an invalid email?

Testing Fundamentals
def validate_email(email):
    import re
    pattern = r'^[\w\.-]+@[\w\.-]+\.\w+$'
    return bool(re.match(pattern, email))
Aassert validate_email('user@domain') == True
Bassert validate_email('user@domain') == False
Cassert validate_email('user@domain.com') == False
Dassert validate_email('userdomain.com') == True
Attempts:
2 left
💡 Hint

Consider if 'user@domain' is a valid email format.

🔧 Debug
advanced
2:00remaining
Find the Bug in Validation Code

What error will this JavaScript code produce when validating a number input?

Testing Fundamentals
function validateNumber(input) {
  if (typeof input === 'number' && input > 0) {
    return true;
  } else {
    return false;
  }
}

console.log(validateNumber('5'));
AReturns false
BReturns true
CThrows TypeError
DReturns undefined
Attempts:
2 left
💡 Hint

Check the type of the input '5' (string) compared to number.

framework
expert
2:00remaining
Choosing Best Locator for Validation Error Message

In automated UI testing, which locator is best to find a validation error message that appears below an input field with id 'username'?

ABy.id('username')
BBy.tagName('span')
CBy.className('error')
DBy.xpath("//input[@id='username']/following-sibling::span[@class='error']")
Attempts:
2 left
💡 Hint

Think about locating the error message specifically related to the username input.