0
0
Testing Fundamentalstesting~20 mins

Test environment setup in Testing Fundamentals - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Test Environment Setup Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Why isolate test environments?

Why is it important to keep the test environment separate from the production environment?

ATo reduce the need for backups in the production environment.
BTo make sure the test environment uses the same hardware as production for cost savings.
CTo allow testers to access production data directly for faster testing.
DTo prevent test data from affecting real users and to avoid accidental changes to live systems.
Attempts:
2 left
💡 Hint

Think about what could happen if test data mixes with real user data.

Predict Output
intermediate
2:00remaining
Test environment variable usage

What will be the output of this Python code snippet simulating environment setup?

Testing Fundamentals
import os
os.environ['ENV'] = 'test'
if os.getenv('ENV') == 'test':
    print('Running in test environment')
else:
    print('Running in production')
ARunning in production
BKeyError exception
CRunning in test environment
DNo output
Attempts:
2 left
💡 Hint

Check what value is set for the 'ENV' variable before the condition.

🔧 Debug
advanced
2:30remaining
Fix the test environment configuration error

Given this configuration snippet for a test environment, which option correctly fixes the error causing tests to connect to production database?

Testing Fundamentals
config = {
    'database_url': 'prod-db.example.com',
    'environment': 'test'
}

# Tests should connect to 'test-db.example.com' instead
AChange 'database_url' to 'test-db.example.com' in the config dictionary.
BChange 'environment' to 'production' in the config dictionary.
CRemove the 'database_url' key from the config dictionary.
DAdd a new key 'db_url' with value 'test-db.example.com' without changing 'database_url'.
Attempts:
2 left
💡 Hint

Check which database URL the tests are currently using and what they should use.

assertion
advanced
2:00remaining
Valid assertion for test environment variable

Which assertion correctly verifies that the environment variable 'MODE' is set to 'testing' in Python?

Testing Fundamentals
import os
os.environ['MODE'] = 'testing'
Aassert os.environ['MODE'] = 'testing'
Bassert os.getenv('MODE') == 'testing'
Cassert os.getenv('MODE') != 'testing'
Dassert os.environ.get('MODE') == 'production'
Attempts:
2 left
💡 Hint

Remember the difference between assignment (=) and comparison (==) in assertions.

framework
expert
3:00remaining
Best practice for test environment setup in CI/CD pipelines

In a Continuous Integration/Continuous Deployment (CI/CD) pipeline, what is the best practice to ensure the test environment is correctly set up before running automated tests?

AUse infrastructure as code scripts to provision and configure the test environment automatically before tests run.
BManually configure the test environment once and reuse it for all future test runs without changes.
CSkip environment setup and rely on default settings of the testing framework.
DRun tests directly on the production environment to save setup time.
Attempts:
2 left
💡 Hint

Think about automation and consistency in CI/CD pipelines.