0Pricing
Learn Rust Coding · Ders

Tümleştirme Testleri

tests dizini

Tümleştirme Testleri, CoddyKit'te ücretsiz bir Learn Rust Coding dersidir. Bu, 4 dersinin 2. dersidir. Aşağıdan dersin tamamını ücretsiz okuyabilir, sonra tarayıcıda yerleşik kod editörü ve 7/24 yapay zeka koçu ile uygulamalı olarak pratik yapabilirsin. Bu, Learn Rust Coding öğrenme yolunun bir parçasıdır ve ilerlemeniz web ve CoddyKit uygulaması arasında senkronize olur. Learn Rust Coding kursu toplamda 4 dersten oluşur.

Bu dersin bazı bölümleri henüz çevrilmemiş olup İngilizce olarak gösterilmektedir.

What Are Integration Tests?

Integration tests verify your crate's public API the way an external user would. They live outside src and can only call public items.

The tests Directory

Cargo treats every file in the top-level tests/ directory as a separate test crate. No #[cfg(test)] module is needed there.

  • tests/api.rs
  • tests/parsing.rs

A Library to Test

Integration tests target a library crate. Suppose src/lib.rs exposes a public function.

// src/lib.rs
pub fn add(a: i32, b: i32) -> i32 {
    a + b
}

Writing an Integration Test

In tests/add.rs, import the crate by name and test its public API. Each function still uses #[test].

// tests/add.rs
use my_lib::add;

#[test]
fn adds_two_numbers() {
    assert_eq!(add(2, 2), 4);
}

Public Only

Because integration tests are a separate crate, they can use only public (pub) items. Private functions are invisible — just like to any real consumer.

Running Integration Tests

cargo test runs unit and integration tests together. Each file under tests/ appears as its own test binary in the output.

cargo test

Running One File

Use --test with the file name (without extension) to run a single integration test file.

cargo test --test add

Shared Test Helpers

To share setup code without making it a test file, put helpers in tests/common/mod.rs. Files in subdirectories are not treated as test crates.

// tests/common/mod.rs
pub fn setup() {
    // shared setup logic
}

Using the Helper

Declare the module and call its functions from your integration test.

// tests/api.rs
mod common;

#[test]
fn uses_setup() {
    common::setup();
    assert!(true);
}

Unit vs Integration

Two complementary test styles:

  • Unit tests live in src, can test private items, fast and focused
  • Integration tests live in tests/, test the public API end to end

Testing a Binary Crate

Integration tests target libraries, not binaries. A common pattern is to keep logic in src/lib.rs and have a thin src/main.rs that calls it, so both unit and integration tests can reach the code.

// src/main.rs
fn main() {
    println!("{}", my_lib::add(2, 3));
}

Quick Check

Where do integration tests live, and what can they access?

Recap

You learned integration testing:

  • Files in tests/ are separate test crates
  • They import your crate by name and test only public items
  • cargo test --test name runs one file
  • Shared helpers go in tests/common/mod.rs

Sıkça Sorulan Sorular

“Tümleştirme Testleri” dersi ücretsiz mi?

Evet — “Tümleştirme Testleri” dersin tüm metni burada web'de ücretsiz olarak okunabilir. Etkileşimli olarak pratik yapmak (yerleşik kod editörü ve 7/24 yapay zeka koçu) ve Learn Rust Coding kursunun geri kalanını açmak için CoddyKit PRO'ya yükselt. Learn Rust Coding kursu toplamda 4 dersten oluşur.

“Tümleştirme Testleri” dersinde ne öğreneceğim?

tests dizini Learn Rust Coding ile uygulamalı kodu tarayıcıda doğrudan çalıştırarak pratik yaparsın ve 7/24 yapay zeka koçu dersi çalışırken sorularını yanıtlar.

Learn Rust Coding öğrenmeye başlamak için deneyim gerekli mi?

Önceden deneyim gerekmez. CoddyKit'te Learn Rust Coding, başlangıçtan ileri seviyeye kadar yapılandırıldığı için buradan başlayabilir veya başından başlayıp kendi hızında ilerleme yapabilirsin. Bu, 4 dersinin 2. dersidir.

“Tümleştirme Testleri” dersi ne kadar sürer?

Çoğu CoddyKit dersi yaklaşık 5–10 dakika sürer. Her biri kısa ve etkileşimli olduğu için sabit ilerleme yaparsın ve web ile uygulama arasında tam olarak bıraktığın yerden devam edebilirsin.

Bu Learn Rust Coding dersinde kod yazıp çalıştırabilir miyim?

Evet. Her Learn Rust Coding dersi yerleşik bir kod editörü içerir, bu sayede tarayıcıda gerçek kod yazıp çalıştırabilir ve anlık yapay zeka geri bildirimi alırsın — yerel kurulum gerekli değildir.

Bu kursun tüm dersleri

  1. Birim Testleri
  2. Tümleştirme Testleri
  3. Belge Açıklamaları
  4. Belge Testleri
← Learn Rust Coding Sayfasına Dön