Tutte le specialitàTecnologia · Colloquio di lavoro

Testing

I colloqui sul testing riguardano il giudizio: che cosa testare, quanto in profondità e che cosa fare quando i test non sono affidabili. Allena queste risposte a voce alta, con una struttura chiara.

Parole → espressioni → frasi → parlato

Prova SpeakRole ↗
Colloquio di lavoroTesting
V

How do you decide what to cover with unit tests versus integration tests?

0:18
Domanda dell’intervistatore

Testing

Chi intervista per i ruoli di sviluppatore e di QA vuole vedere una mentalità orientata alla qualità: pensi a che cosa può andare storto, quanto è probabile e come scoprirlo presto. Gli strumenti contano meno del ragionamento. Un candidato che spiega perché esiste un test è più convincente di uno che nomina cinque framework.

Dai ogni risposta in tre passaggi: una breve definizione, un esempio tratto da un progetto reale e il compromesso. Nel testing quasi ogni regola ha un'eccezione, e dirlo mostra che hai lavorato con una vera suite di test e non ne hai solo letto.

  • ✓Parole → espressioni → frasi → parlato
  • ✓Senso della risposta
  • ✓Lingua

Domande comuni e risposte di esempio

What is the test pyramid, and why does it matter?

Che cos'è la piramide dei test e perché è importante?

Che cosa vuole sentire l'intervistatore. L'idea di molti test veloci alla base e pochi test lenti in cima, con la ragione: costo, velocità e chiarezza dei fallimenti.

Risposta di esempio in inglese da esercitare ad alta voce

The test pyramid is a model for balancing tests. At the bottom there are many fast unit tests, in the middle fewer integration tests, and at the top a small number of end-to-end tests through the real interface. The reason is cost. Unit tests run in milliseconds and point to the exact problem. End-to-end tests are slow, fragile and harder to debug, but they check that the whole system works. If a team has mostly end-to-end tests, the feedback is slow and the suite becomes unreliable. I use the pyramid as a guide, not as a law. For a service that is mostly integration with a database, I may write more integration tests.

What is the difference between a unit test and an integration test, and when do you use a mock?

Qual è la differenza tra un test unitario e un test di integrazione e quando usi un mock?

Che cosa vuole sentire l'intervistatore. Definizioni chiare, una regola su che cosa sostituire con un mock e il rischio di usarne troppi (over-mocking).

Risposta di esempio in inglese da esercitare ad alta voce

A unit test checks one small piece of logic, like a function or a class, in isolation. It is fast and does not need a network or a database. An integration test checks that several parts work together, for example my code and a real database. I use a mock or a stub to replace a dependency that is slow, random or outside my control, like a payment gateway or the clock. But I do not mock everything. If a test only checks that my mock was called, it proves little and breaks whenever I refactor. For the database layer, I prefer a real database in a container, because it finds real problems, such as a wrong query.

What is a flaky test, and how do you deal with it?

Che cos'è un test flaky (instabile) e come lo gestisci?

Che cosa vuole sentire l'intervistatore. Le cause tipiche, un metodo per trovare la causa vera e una regola che protegge il team dai fallimenti ignorati.

Risposta di esempio in inglese da esercitare ad alta voce

A flaky test sometimes passes and sometimes fails on the same code. It is dangerous, because people stop trusting the suite and start ignoring red builds. The common causes are fixed waiting times, shared state between tests, random or time-based data, and unstable external services. First I reproduce the problem, by running the test many times or in a different order, and I read the logs. Then I fix the cause: wait for a condition instead of sleeping, isolate the data, control the clock. If I cannot fix it quickly, I quarantine the test and create a ticket, so it does not block everyone. I never just add a retry and forget it.

How do you manage test data?

Come gestisci i dati di test?

Che cosa vuole sentire l'intervistatore. Test isolati, creazione dei dati leggibile e attenzione alla privacy quando entrano in gioco dati reali.

Risposta di esempio in inglese da esercitare ad alta voce

Good test data is realistic, isolated and easy to understand. For unit tests, I create the data inside the test with small builders or factory functions, so the reader sees what matters. For integration and end-to-end tests, each test should create the data that it needs and clean up after itself, or run in a transaction that is rolled back, so tests do not depend on each other. I avoid sharing one big database dump, because nobody knows what is inside, and one change breaks many tests. I never copy real customer data into a test environment without anonymising it, because of privacy rules.

What is test-driven development, and do you use it?

Che cos'è il test-driven development e lo usi?

Che cosa vuole sentire l'intervistatore. Il ciclo red, green, refactor, i vantaggi reali e una valutazione onesta di dove è adatto e dove no.

Risposta di esempio in inglese da esercitare ad alta voce

TDD means test-driven development. I write a failing test first, then the smallest amount of code that makes it pass, and then I refactor while the tests stay green. This is the red, green, refactor cycle. The benefit is that I think about the behaviour and the interface before the implementation, and I get a safety net for later changes. I find it most useful for business logic and for bug fixes: I first write a test that reproduces the bug. I use it less for exploratory work, like a new user interface, where I do not yet know what I am building. For me, it is a tool, not a rule.

Come pronunciare i termini chiave

mock
moc (rima con «clock»)
flaky
flèi-chi
regression
ri-grèsh-on
fixture
fìcs-cer
assertion
a-sèr-shon
coverage
càv-er-idj
deterministic
di-tèr-mi-nìs-tic

Frasi utili per rispondere

  • I would test the behaviour, not the implementation.Testerei il comportamento, non l'implementazione.
  • First I write a failing test that reproduces the bug.Prima scrivo un test che fallisce e riproduce il bug.
  • I would mock only what I do not control.Userei un mock solo per ciò che non controllo.
  • What is the risk if this fails in production?Qual è il rischio se questo fallisce in produzione?
  • The test should fail for one reason only.Il test dovrebbe fallire per un solo motivo.
  • I would make the test deterministic first.Prima renderei il test deterministico.
  • That belongs in a unit test, not an end-to-end test.Questo appartiene a un test unitario, non a un test end-to-end.

Errori comuni da evitare

  • Citare "90 percent coverage" come prova di qualità. La coverage mostra quali righe sono state eseguite, non se i test controllano qualcosa di utile. Di' che cosa proteggono i tuoi test.
  • Dire "I made a test" o "I did a bug", sul modello di «ho fatto un test». Le collocazioni usuali sono "write a test", "run the tests", "find a bug" e "fix a bug". Impara queste combinazioni come blocchi già pronti.
  • Descrivere il testing come «cliccare in giro per l'applicazione». Parla di rischio, automazione e di dove si colloca ciascun tipo di test.
  • Dare la colpa agli altri, per esempio "developers write bad code" o "QA is too slow". Una risposta forte mostra una responsabilità condivisa sulla qualità.
  • Dire che testi tutto. Nessuno può farlo, quindi spiega come scegli: in base al rischio, all'impatto e alla frequenza con cui il codice cambia.

Domande frequenti

Devo conoscere un framework di test specifico?

Nomina quello che hai usato, per esempio JUnit, pytest o Jest, e spiega come hai strutturato i test con esso. Concetti come isolamento, mock e dati di test sono gli stessi in ogni framework, e a chi intervista interessano di più.

Come mostro una mentalità da QA in un colloquio?

Parla di rischio e di utenti: che cosa potrebbe andare storto, quale sarebbe l'impatto e come lo scopriresti presto. Cita i casi limite, l'exploratory testing e bug report chiari con i passaggi per riprodurre il problema. Funziona bene una breve storia su un bug che hai trovato prima del rilascio.

E se mi chiedono di scrivere dei test case al momento?

Pensa ad alta voce e usa un ordine semplice: il caso normale, i valori limite, l'input vuoto o non valido e i casi di errore. Dire le categorie a voce alta mostra struttura, anche se non hai il tempo di scrivere ogni caso.

Leggere una risposta non è la stessa cosa che dirla. Esercita ogni domanda ad alta voce, poi confronta il significato e la lingua della tua risposta.

Prova SpeakRole ↗

Altri argomenti in quest’area