VHow do you decide what to cover with unit tests versus integration tests?
Mülakat sorusuTest
Geliştirici ve QA pozisyonlarının mülakatçıları bir kalite zihniyeti görmek ister: neyin ters gidebileceğini, bunun ne kadar olası olduğunu ve erkenden nasıl bulunacağını düşünürsünüz. Araçlar, akıl yürütmeden daha az önemlidir. Bir testin neden var olduğunu açıklayan aday, beş framework sayan adaydan daha güçlüdür.
Her cevabı üç adımda verin: kısa bir tanım, gerçek bir projeden örnek ve ödünleşim (trade-off). Testte neredeyse her kuralın bir istisnası vardır ve bunu söylemek, bir test paketini yalnızca okumadığınızı, onunla gerçekten çalıştığınızı gösterir.
- ✓Kelimeler → ifadeler → cümleler → konuşma
- ✓Yanıtın anlamı
- ✓Dil
Sık sorulan mülakat soruları ve örnek cevaplar
What is the test pyramid, and why does it matter?
Test piramidi nedir ve neden önemlidir?
Mülakatçı ne duymak ister. Altta çok sayıda hızlı, üstte az sayıda yavaş test fikri ve nedeni: maliyet, hız ve hataların netliği.
Yüksek sesle çalışmak için İngilizce örnek cevapThe 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?
Birim testi ile entegrasyon testi arasındaki fark nedir ve mock'u ne zaman kullanırsınız?
Mülakatçı ne duymak ister. Net tanımlar, neyin mock ile değiştirileceğine dair bir kural ve aşırı mock'lama riski.
Yüksek sesle çalışmak için İngilizce örnek cevapA 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?
Flaky test nedir ve onunla nasıl başa çıkarsınız?
Mülakatçı ne duymak ister. Tipik nedenler, gerçek nedeni bulma yöntemi ve ekibi görmezden gelinen hatalardan koruyan bir politika.
Yüksek sesle çalışmak için İngilizce örnek cevapA 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?
Test verisini nasıl yönetirsiniz?
Mülakatçı ne duymak ister. Birbirinden yalıtılmış testler, okunabilir veri oluşturma ve gerçek veri söz konusu olduğunda gizliliğe dikkat.
Yüksek sesle çalışmak için İngilizce örnek cevapGood 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?
Test güdümlü geliştirme (TDD) nedir ve kullanıyor musunuz?
Mülakatçı ne duymak ister. Kırmızı, yeşil, yeniden düzenleme (refactor) döngüsü, gerçek faydalar ve nerede uygun olduğuna, nerede olmadığına dürüst bir bakış.
Yüksek sesle çalışmak için İngilizce örnek cevapTDD 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.
Anahtar terimler nasıl telaffuz edilir
- mock
- mok (“clock” ile uyaklı)
- flaky
- FLEY-ki
- regression
- ri-GREŞ-ın
- fixture
- FİKS-çır
- assertion
- ı-SÖR-şın
- coverage
- KAV-ır-ic
- deterministic
- di-TÖR-mi-NİS-tik
Cevap vermek için kullanışlı kalıplar
- I would test the behaviour, not the implementation.Uygulamayı değil, davranışı test ederdim.
- First I write a failing test that reproduces the bug.Önce hatayı yeniden üreten, başarısız olan bir test yazarım.
- I would mock only what I do not control.Yalnızca kontrol etmediğim şeyleri mock'lardım.
- What is the risk if this fails in production?Bu canlıda başarısız olursa risk nedir?
- The test should fail for one reason only.Test yalnızca tek bir nedenle başarısız olmalı.
- I would make the test deterministic first.Önce testi deterministik hâle getirirdim.
- That belongs in a unit test, not an end-to-end test.Bu bir birim testine ait, uçtan uca (end-to-end) teste değil.
Sık yapılan hatalar
- "90 percent coverage"ı kalitenin kanıtı olarak sunmak. Coverage hangi satırların çalıştığını gösterir; testlerin yararlı bir şey kontrol edip etmediğini göstermez. Testlerinizin neyi koruduğunu söyleyin.
- "I made a test" ya da "I did a bug" demek. Olağan sözcük birliktelikleri "write a test", "run the tests", "find a bug" ve "fix a bug" şeklindedir. Bunları hazır kalıplar olarak öğrenin. Türkçedeki “test yapmak” ve “hata yapmak” ifadelerini birebir çevirmek bu hataya yol açar.
- Testi "uygulamada tıklayıp gezmek" olarak anlatmak. Risk, otomasyon ve her test türünün nereye oturduğu hakkında konuşun.
- Başkalarını suçlamak; örneğin "developers write bad code" ya da "QA is too slow". Güçlü bir cevap, kalitenin ortak sahiplenildiğini gösterir.
- Her şeyi test ettiğinizi söylemek. Kimse yapamaz; bu yüzden nasıl seçtiğinizi açıklayın: riske, etkiye ve kodun ne sıklıkla değiştiğine göre.
Sıkça sorulan sorular
Belirli bir test framework'ünü bilmem gerekir mi?
Kullandığınızı söyleyin; örneğin JUnit, pytest ya da Jest ve testleri onunla nasıl yapılandırdığınızı açıklayın. Yalıtım, mock'lar ve test verisi gibi kavramlar her framework'te aynıdır ve mülakatçılar onlara daha çok önem verir.
Mülakatta QA zihniyetini nasıl gösteririm?
Risk ve kullanıcılar üzerine konuşun: neyin ters gidebileceği, etkisinin ne olacağı ve bunu erkenden nasıl bulacağınız. Uç durumlardan (edge cases), keşif testinden (exploratory testing) ve tekrar adımlarıyla (steps to reproduce) net hata raporlarından söz edin. Yayından önce bulduğunuz bir hatayla ilgili kısa bir hikâye iyi işler.
Anında test senaryoları yazmam istenirse ne yapmalıyım?
Yüksek sesle düşünün ve basit bir sıra kullanın: normal durum, sınır değerler, boş ya da geçersiz girdi ve hata durumları. Kategorileri yüksek sesle söylemek, her senaryoyu yazmaya vaktiniz olmasa bile yapı gösterir.
Bir cevabı okumak ile onu söylemek aynı şey değildir. Her soruyu yüksek sesle çalışın, ardından kendi cevabınızın anlamını ve dilini karşılaştırın.
SpeakRole’i dene ↗Bu alandaki diğer konular