pytest ile entegrasyon testi

Python'da Teste Giriş

Alexander Levin

Data Scientist

Entegrasyon testi nedir?

  • Entegrasyon testi: Bir etkileşimin normal davrandığını doğrulayan yazılım test yöntemi.

  • Entegrasyon: Bir sistem içindeki 2 veya daha fazla modülün etkileşimi.

entegrasyon örneği diyagramı

Python'da Teste Giriş

Gerçek projelerde entegrasyonlar

Örnekler:

  • Güç kablosu
  • İnternet bağlantısı
  • Dosya okuma sürücüsü
  • Veritabanı bağlantısı
  • Uygulama Programlama Arayüzü (API) entegrasyonu
Python'da Teste Giriş

Neler ters gidebilir

Olası entegrasyon sorunları:

  • Bağlantı kopması
  • Veri kaybı
  • Etkileşim gecikmeleri
  • Düşük bant genişliği
  • Sürüm çakışmaları
  • Arayüz uyumsuzluğu
  • Diğerleri
Python'da Teste Giriş

Entegrasyon testi örneği

import pytest, os

@pytest.fixture
def setup_file():
    # Create temporary file
    file = "test_file.txt"
    with open(file, "w") as f1:
        f1.write("Test data 1")
    yield file
    os.remove(file)

def test_fs(setup_file):
    file = setup_file
    # Check that the file was created successfully
    assert os.path.exists(file)
Python'da Teste Giriş

Özet

  • Entegrasyon testi: Entegrasyonun beklendiği gibi çalıştığını doğrulayan yazılım test yöntemidir.

  • Gerçek projeler birçok farklı entegrasyon içerir.

  • Entegrasyon testi, olası sorunların çoğunu önlemeye yardımcı olur.

  • Örnek: Python ile dosya sistemi arasındaki entegrasyonu kontrol etme.

Python'da Teste Giriş

Hadi pratik yapalım!

Python'da Teste Giriş

Preparing Video For Download...