Software Engineering Intern Interview Question

How do you test your own code?

What the interviewer is probing, how to structure your answer, and a spoken example you can adapt.

Quick answer

Write automated tests alongside the code, mainly unit tests for individual functions, covering the normal case, edge cases such as empty or very large inputs, and invalid inputs that should be rejected. Add a few integration tests for how the pieces work together, and run everything before each commit. When you find a bug, write a test that reproduces it first, then fix it. Manual checking helps, but it does not replace automated tests.

Why interviewers ask this

Teams want interns who check their own work rather than relying on reviewers to find bugs. The interviewer wants to hear about automated tests, how you choose test cases, especially edge cases, and the habit of turning bugs into tests. Naming the testing framework you have used and describing what a good test looks like shows practical experience rather than a general belief that testing matters.

How to structure your answer

  • Describe the kinds of tests you write.
  • Explain how you choose test cases, especially edge cases.
  • Mention when you run tests and how bugs become tests.
  • Give a short example from a real project.

Example answer

Spoken example, first person

I write automated tests as I go rather than at the end, mostly unit tests that check one function at a time. In Python I use pytest, and I used JUnit for a Java coursework project. For each function I think about three kinds of input. The normal case, to prove it does its job. Edge cases, like an empty list, a single item, very large numbers or duplicates, because that is where most of my bugs have been. And invalid input, to check it fails clearly instead of returning nonsense. Each test checks one thing and has a name saying what it proves, so when one fails I know what broke without reading the code. For parts that connect to each other, like an endpoint saving to a database, I add a few integration tests. I run the tests before every commit, and in our last group project we set up a pipeline that ran them on every pull request. When I find a bug, I write a failing test that reproduces it first, then fix the code, so it cannot come back. I still click through the app before a demo, but as an extra check.

Walking into this interview soon? GhostPilot listens to your live call, spots the question the moment it is asked, and puts a structured answer on your screen in real time. Try it on your next mock, or grab a $29 Session Pass, no subscription, for the real thing.

See how it works

Follow-up questions to expect

  • How do you test a function that depends on the current date or a random number?
  • What is the difference between a unit test and an integration test?
  • How much test coverage is enough?

Related software engineering intern questions

Your interviewer will ask their own version of this. Paste your actual job description into the free Question Predictor and get the 20 questions that role is most likely to ask, with what each one is really probing.

Predict my questions

Rehearse the hard questions before they are asked

Practise with a live copilot, then walk in ready. A $29 Session Pass gets you through the interview with no subscription and no lock-in.

Get GhostPilot