Struct CoverageReport

Source
pub struct CoverageReport {
    pub visited_states: HashSet<String>,
    pub visited_transitions: HashSet<String>,
    pub total_states: usize,
    pub total_transitions: usize,
}
Expand description

カバレッジ情報を表す構造体

Fields§

§visited_states: HashSet<String>

テストされた状態

§visited_transitions: HashSet<String>

テストされた遷移

§total_states: usize

全状態の数

§total_transitions: usize

全遷移の数

Implementations§

Source§

impl CoverageReport

Source

pub fn state_coverage(&self) -> f64

状態カバレッジの割合(%)を計算

Examples found in repository?
examples/model_based_testing.rs (line 180)
172fn print_test_results(results: &rustate::TestResults) {
173    println!("総テスト数: {}", results.total_count());
174    println!("成功: {}", results.success_count());
175    println!("失敗: {}", results.failure_count());
176    println!("成功率: {:.1}%", results.success_rate());
177
178    // カバレッジレポート
179    let coverage = results.get_coverage();
180    println!("状態カバレッジ: {:.1}%", coverage.state_coverage());
181    println!("遷移カバレッジ: {:.1}%", coverage.transition_coverage());
182
183    // 失敗したテストがあれば詳細を表示
184    let failed_tests = results
185        .results
186        .iter()
187        .filter(|r| !r.success)
188        .collect::<Vec<_>>();
189    if !failed_tests.is_empty() {
190        println!("\n失敗したテスト:");
191        for failed in failed_tests {
192            println!(
193                "- {}: 期待={}, 実際={}",
194                failed.test_name, failed.expected_state, failed.actual_state
195            );
196            if let Some(err) = &failed.error_message {
197                println!("  エラー: {}", err);
198            }
199        }
200    }
201}
Source

pub fn transition_coverage(&self) -> f64

遷移カバレッジの割合(%)を計算

Examples found in repository?
examples/model_based_testing.rs (line 181)
172fn print_test_results(results: &rustate::TestResults) {
173    println!("総テスト数: {}", results.total_count());
174    println!("成功: {}", results.success_count());
175    println!("失敗: {}", results.failure_count());
176    println!("成功率: {:.1}%", results.success_rate());
177
178    // カバレッジレポート
179    let coverage = results.get_coverage();
180    println!("状態カバレッジ: {:.1}%", coverage.state_coverage());
181    println!("遷移カバレッジ: {:.1}%", coverage.transition_coverage());
182
183    // 失敗したテストがあれば詳細を表示
184    let failed_tests = results
185        .results
186        .iter()
187        .filter(|r| !r.success)
188        .collect::<Vec<_>>();
189    if !failed_tests.is_empty() {
190        println!("\n失敗したテスト:");
191        for failed in failed_tests {
192            println!(
193                "- {}: 期待={}, 実際={}",
194                failed.test_name, failed.expected_state, failed.actual_state
195            );
196            if let Some(err) = &failed.error_message {
197                println!("  エラー: {}", err);
198            }
199        }
200    }
201}

Trait Implementations§

Source§

impl Clone for CoverageReport

Source§

fn clone(&self) -> CoverageReport

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CoverageReport

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for CoverageReport

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for CoverageReport

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,