PocketFM – Senior SDET Interview (Round 1)
PocketFM – Senior SDET Interview (Round 1)
Questions & Sample Answers
Overview: These were the actual questions that were asked to me in the PocketFM Senior SDET (Round 1) interview.
My experience level at the time of the interview was 4+ years.
The round focused on:
Pytest concepts (fixtures, scopes, conftest)
CI/CD and Jenkins
Reporting strategies
Debugging production-like issues (local vs Jenkins failures)
SQL problem solving
Binary Search and algorithm complexity
API automation logic implementation
Framework design and scalability
Docker and Jenkinsfile usage
DB and Kafka validation integration
The discussion was a mix of:
Conceptual understanding
Hands-on coding
Framework design thinking
Real-world debugging scenarios
1. What are fixtures in Pytest?
Fixtures in Pytest are reusable setup and teardown components used to provide dependencies to test cases.
They help to:
Avoid code duplication
Improve modularity
Manage setup and cleanup logic
Inject dependencies directly into test functions
Example:
import pytest
@pytest.fixture
def user_data():
return {"name": "Alice", "age": 25}
def test_user(user_data):
assert user_data["name"] == "Alice"
Fixtures are automatically injected when passed as parameters to test functions.
2. Explain fixture scopes in Pytest (session vs function).
🔹 Function Scope (Default)
Runs before every test function
Provides a fresh instance per test
Ensures complete test isolation
@pytest.fixture(scope="function")
def db_connection():
return connect_db()
🔹 Session Scope
Runs once per test session
Shared across all test cases
Used for expensive setup like database or server initialization
@pytest.fixture(scope="session")
def db_connection():
conn = connect_db()
yield conn
conn.close()
3. How does Jenkins work in a CI/CD pipeline?
Jenkins is an automation server used for Continuous Integration and Continuous Deployment.
Workflow:
Developer pushes code to Git.
Jenkins detects changes (webhook/polling).
Jenkins pulls the latest code.
Installs dependencies.
Executes build and automation tests.
Generates reports.
Deploys if configured.
The pipeline is defined using a Jenkinsfile (Pipeline as Code).
4. How do you implement reporting in your automation framework?
Common reporting approaches:
Pytest HTML plugin
Allure Reports
Jenkins archived artifacts
Logs and screenshots (for UI automation)
Execution summary with stack traces
Example:
pytest --html=report.html
For production-level frameworks, Allure is preferred due to better visualization and history tracking.
5. If a test passes locally but fails in Jenkins, what will you check?
Checklist:
Python version mismatch
Dependency version differences
Missing environment variables
Base URL or configuration mismatch
Timing or wait issues
Parallel execution conflicts
Database or network accessibility
Test data differences
OS-specific path issues
6. Write a SQL query to find the second highest salary from an Employee table.
Question Link: https://leetcode.com/problems/second-highest-salary/description/
SELECT MAX(salary) AS SecondHighestSalary
FROM Employee
WHERE salary < (SELECT MAX(salary) FROM Employee);
7. Solve: Find First and Last Position of Element in Sorted Array.
Question Link: https://leetcode.com/problems/find-first-and-last-position-of-element-in-sorted-array/description/
Approach:
Perform binary search twice
First to find the first occurrence
Second to find the last occurrence
Time Complexity:
O(log n)
Each iteration halves the search space.
class Solution:
def searchRange(self, nums: List[int], target: int) -> List[int]:
def binary_search(find_first: bool) -> int:
left, right = 0, len(nums) - 1
ans = -1
while left <= right:
mid = (left + right) // 2
if nums[mid] == target:
ans = mid
if find_first:
right = mid - 1 # Move left to find first occurrence
else:
left = mid + 1 # Move right to find last occurrence
elif nums[mid] < target:
left = mid + 1
else:
right = mid - 1
return ans
first = binary_search(find_first=True)
if first == -1:
return [-1, -1]
last = binary_search(find_first=False)
return [first, last]
8. What is the time complexity of Binary Search?
O(log n)
Because each iteration divides the search space into half.
Binary Search is efficient for sorted data.
9. Given an API response JSON, calculate total reward points for a specific book for today.
from datetime import date
today = date.today().strftime("%Y-%m-%d")
total = 0
for record in response.get("result", []):
if (
record.get("book_name") == "JDJFN"
and record.get("create_time") == today
):
total += record.get("balance", 0)
return total
Time Complexity:
O(n) — since we iterate through all records once.
10. Explain the purpose of conftest.py in Pytest.
Stores shared fixtures
No need to import fixtures explicitly
Makes fixtures globally available
Common uses:
Database connections
API clients
Authentication tokens
Test hooks
11. How would you structure an automation framework for API, DB, and Kafka testing?
Example Structure:
src/
└── functional_tests/
└── python/
├── clients/ # API / Kafka / DB clients
│ ├── api_client.py
│ ├── kafka_client.py
│ └── db_client.py
│
├── utils/ # helper functions
│ ├── os_utils.py
│ ├── data_utils.py
│ └── assertions.py
│
├── resources/
│ ├── testdata/ # JSON, CSV, YAML, etc
│ └── payloads/ # request body templates
│
├── schemas/ # response schemas
│ ├── user_schema.json
│ ├── payment_schema.json
│ └── ...
│
├── config/
│ ├── config.ini # base url, db string
│ └── .env.example # actual .env local only
│
├── tests/
│ ├── test_user_flows.py
│ ├── test_payment_flows.py
│ └── ...
│
├── conftest.py # pytest fixtures
├── pytest.ini # markers, hooks
├── requirements.txt
├── Dockerfile
├── run_tests.sh # .sh file with pytest cmds
├── Makefile
├── README.md
└── CODEOWNERS In Root Level: --- .gitignore --- Jenkinsfile # dev + tests
Design Principles:
Separation of concerns
Reusable client layer
Config-driven approach
Scalable for microservices
12. What is the purpose of .env, config.ini, and pytest.ini?
.env
Stores environment variables
Stores secrets like DB URLs and tokens
config.ini
Base URL
Database configurations
Environment-specific settings
pytest.ini
Pytest configuration
Markers
Default options
Test discovery rules
13. How do you containerize your automation framework using Docker?
Dockerfile:
FROM python:3.10
WORKDIR /app
COPY . .
RUN pip install -r requirements.txt
CMD ["pytest"]
Commands:
docker build -t api-tests .
docker run api-tests
Benefits:
Environment consistency
Eliminates “works on my machine” issues
Easy CI integration
14. What is the role of a Jenkinsfile in CI/CD?
A Jenkinsfile defines the pipeline stages such as:
Checkout
Build
Test
Report
Deploy
It is:
Pipeline as Code
Version controlled
Supports parallel execution
15. How would you integrate DB validation and Kafka validation into API automation tests?
End-to-End Validation Flow:
Trigger the API.
Validate API response.
Query the database to validate data persistence.
Consume Kafka topic.
Validate message payload and schema.
Assert consistency across API, DB, and Kafka systems.
This ensures complete system-level validation.
Key Takeaways
-
Senior SDET interviews test architecture thinking, not just scripting.
-
Be prepared for debugging-based scenarios.
-
Strong fundamentals in algorithms and SQL are important.
-
CI/CD and system validation knowledge differentiates mid-level from senior-level candidates.
Comments
Post a Comment