▸case-01 I am writing unit tests in Python for a PaymentGateway client class that connects to Stripe. A coworker suggested using unittest.mock.Mock() without configuring autospec=True or spec because it accepts any method call and attribute access without complaining, making test setup faster. Should I use un-configured Mock() or enable autospec=True when mocking the gateway dependency, and why? | pass→pass | 20,417 | 19,064 | -7% | 1 | 1 | 0% | 2,711 | 2,907 | +7% | 0 | 0 | — |
▸case-02 When testing a module in Node.js that imports an internal logger.log utility, I want to verify that logger.log is called when createUser executes, while preserving the ability to restore the original logger.log function after the test suite finishes. Someone recommended reassigning logger.log = jest.fn() directly in the test file. What jest method should be used instead of manual reassignment, and how should cleanup be handled? | pass→pass | 14,191 | 14,501 | +2% | 1 | 1 | 0% | 1,956 | 2,157 | +10% | 0 | 0 | — |
▸case-03 We are building an integration test suite for a React frontend app that fetches /api/users. A junior dev wants to mock window.fetch directly by setting global.fetch = jest.fn().mockResolvedValue(...) in every test component. We want to test real network request lifecycle without monkeypatching global fetch. Which API mocking pattern or library should we adopt to intercept HTTP requests at the network layer? | pass→pass | 16,522 | 18,435 | +12% | 1 | 1 | 0% | 2,174 | 2,860 | +32% | 0 | 0 | — |
▸case-04 In a Python pytest suite, we need to mock an environment variable DATABASE_URL and an external service function fetch_user_data for a specific test function, ensuring that changes do not leak into other test cases. Should we modify os.environ manually and reset it in a finally block, or use pytest's built-in fixture for safe scoped context modification? | pass→pass | 14,135 | 15,250 | +8% | 1 | 1 | 0% | 1,933 | 2,361 | +22% | 0 | 0 | — |
▸case-05 In a Java Spring Boot unit test using Mockito, we mock EmailService. We want to assert that sendEmail was called with expected arguments, and also strictly ensure no other unexpected methods were called on EmailService during the execution. Should we manually count invocations or use a specific Mockito verification utility? | pass→pass | 15,025 | 16,912 | +13% | 1 | 1 | 0% | 1,888 | 2,300 | +22% | 0 | 0 | — |
▸case-06 We are testing a client retry mechanism for a payment service using WireMock. On the first HTTP POST call to /charge, the server should return a 503 Service Unavailable, but on the second attempt, it should return 200 OK. How should WireMock be configured to simulate this dynamic sequential state change? | pass→pass | 17,861 | 14,868 | -17% | 1 | 1 | 0% | 2,113 | 2,498 | +18% | 0 | 0 | — |
▸case-07 In a Go microservice, we want to unit test a OrderService struct that depends on a Repository interface. Should we manually create a struct with function fields or generate mock implementations using official Go tooling? | pass→pass | 14,015 | 15,091 | +8% | 1 | 1 | 0% | 2,607 | 3,052 | +17% | 0 | 0 | — |
▸case-08 When writing pytest tests that require mocking multiple external API clients, a developer is using nested 'with patch(module.A) as mock_a: with patch(module.B) as mock_b:' decorators and context managers inside test functions. Is there a cleaner pytest-native alternative that manages mock lifecycles automatically across the test scope without heavy indentation? | pass→pass | 11,867 | 16,982 | +43% | 1 | 1 | 0% | 2,375 | 2,750 | +16% | 0 | 0 | — |
▸case-09 We have code that checks if a user token is expired by calling datetime.now() or Date.now(). In unit tests, developers are using time.sleep() to wait for tokens to expire, making the test suite slow and non-deterministic. What technique or pattern should be used to test time-dependent logic reliably? | pass→pass | 12,047 | 19,112 | +59% | 1 | 1 | 0% | 2,522 | 3,252 | +29% | 0 | 0 | — |
▸case-10 In Jest, a developer wrote import { client } from './api'; at the top of the file, and then inside a test() block wrote jest.mock('./api'). However, the mock doesn't seem to apply before the module is imported. How does Jest handle jest.mock calls and where should jest.mock be placed? | pass→pass | 11,830 | 15,211 | +29% | 1 | 1 | 0% | 2,266 | 2,706 | +19% | 0 | 0 | — |
▸case-11 We are designing a mock for a complex third-party SDK. A developer wants to know whether to create a loose mock (which returns default empty values for unconfigured calls) or a strict mock (which throws an exception for any un-stubbed method call). Which pattern should be preferred when catching unexpected side-effects or contract drifts during unit tests? | pass→pass | 16,246 | 18,276 | +12% | 1 | 1 | 0% | 1,881 | 2,525 | +34% | 0 | 0 | — |
▸case-12 In Python unit testing, we have module app.services.user_service which imports requests as import requests. In test file test_user_service.py, a developer wrote @patch('requests.get'). However, user_service still calls the actual requests.get function. Where should the patch target point to properly mock requests? | pass→pass | 17,496 | 15,308 | -13% | 1 | 1 | 0% | 1,923 | 2,429 | +26% | 0 | 0 | — |
▸case-13 In C# using Moq, we want to mock IUserRepository.GetByIdAsync(1) to return a completed Task with a User object, and return null for any other ID. A developer wants to write separate hardcoded mock objects for every ID value. How should Moq setup and argument matchers be configured for this behavior? | fail→pass | 13,908 | 11,537 | -17% | 1 | 1 | 0% | 2,441 | 2,542 | +4% | 0 | 0 | — |
▸case-14 We are writing integration tests for complex SQL queries involving join operations and JSON aggregations. A developer proposed mocking the database ORM connection methods using unittest.mock to return hardcoded raw dictionary lists. Is mocking the database layer appropriate for testing complex SQL query correctness, or what strategy should be used? | pass→pass | 19,636 | 22,112 | +13% | 1 | 1 | 0% | 2,205 | 3,533 | +60% | 0 | 0 | — |
▸case-15 In a TypeScript project using Vitest, we want to mock an imported utility function calculateTax from ./taxUtils. The developer wants to replace the imported function with a dummy inline arrow function. What Vitest utility function should be used to mock and track calls to this function, and how do we mock module imports? | fail→pass | 8,075 | 13,204 | +64% | 1 | 1 | 0% | 1,572 | 1,900 | +21% | 0 | 0 | — |
▸case-16 When two microservices communicate via REST, service A team writes unit tests using standalone WireMock stubs for service B. However, service B team changed their response payload field names and service A's unit tests still passed, breaking production. What testing strategy or tool type prevents mock-drift between microservices? | pass→pass | 14,498 | 17,246 | +19% | 1 | 1 | 0% | 1,554 | 2,397 | +54% | 0 | 0 | — |
▸case-17 In C++ using Google Mock (gMock), we need to test that DatabaseWriter::Connect() is called before DatabaseWriter::WriteData(). A developer is writing EXPECT_CALL statements without specifying sequence order. How should gMock enforce the exact relative execution order between these two mock calls? | pass→pass | 17,211 | 16,636 | -3% | 1 | 1 | 0% | 1,973 | 2,731 | +38% | 0 | 0 | — |
▸case-18 In a Python test suite, a developer is using patch.object(MyService, 'helper_method') to mock internal private methods on the class under test. The class has 15 internal methods and 1000 lines of code. What does heavy reliance on partial mocking usually indicate about class design, and what is the recommended refactoring? | pass→pass | 13,913 | 17,931 | +29% | 1 | 1 | 0% | 2,454 | 2,725 | +11% | 0 | 0 | — |
▸case-19 A team is writing unit tests for a service interacting with AWS S3 using boto3. They are trying to mock internal private HTTP response objects from the AWS SDK manually using nested Mock objects. What standard architectural principle applies ('Don't mock what you don't own'), and what abstraction or wrapper layer should be mocked instead? | pass→pass | 10,082 | 12,016 | +19% | 1 | 1 | 0% | 1,790 | 2,633 | +47% | 0 | 0 | — |
▸case-20 We need to execute a performance benchmark on our public REST API endpoint to determine throughput (RPS) and latency under 5,000 concurrent virtual users. Please provide a script and configuration to run this load test using k6. | fail→fail | 15,904 | 20,138 | +27% | 1 | 1 | 0% | 3,003 | 3,506 | +17% | 0 | 0 | — |
▸case-21 We need to run a static application security testing (SAST) audit on our Node.js codebase to check for SQL injection vulnerabilities and insecure dependencies using Semgrep and OWASP guidelines. How should we configure security rules? | fail→fail | 15,599 | 15,333 | -2% | 1 | 1 | 0% | 3,029 | 3,218 | +6% | 0 | 0 | — |
▸case-22 We are conducting a 90-minute session-based manual exploratory testing effort for a new shopping cart checkout feature. Please draft an exploratory test charter detailing session goals, areas to explore, and bug taxonomy. | fail→fail | 20,060 | 19,127 | -5% | 1 | 1 | 0% | 2,504 | 3,462 | +38% | 0 | 0 | — |