config_example/
config_example.rs

1use rest::prelude::*;
2
3// This binary shows different configuration options for FluentTest
4fn main() {
5    println!("FluentTest Configuration Example\n");
6
7    // STEP 1: Standard behavior demonstration
8    println!("1. Standard behavior (no enhanced output):");
9    standard_mode_example();
10
11    // STEP 2: Enhanced output demonstration
12    println!("\n2. With enhanced output enabled:");
13    enhanced_mode_example();
14
15    // Wrap up with additional information
16    println!("\nFor more examples of enhanced output, run:");
17    println!("  cargo run --example enhanced_output");
18
19    println!("\nYou can also enable enhanced output with environment variable:");
20    println!("  FLUENT_TEST_ENHANCED_OUTPUT=true cargo run --example config_example");
21}
22
23// Demonstrates standard error messages (default behavior)
24fn standard_mode_example() {
25    // Create a simple catch_unwind example as a simulation
26    let result = std::panic::catch_unwind(|| {
27        // With default config (no enhanced output), should use standard Rust error format
28        expect!(2 + 2).to_equal(5); // This will fail
29    });
30
31    match result {
32        Ok(_) => println!("  ❌ Test unexpectedly passed"),
33        Err(e) => {
34            if let Some(s) = e.downcast_ref::<String>() {
35                println!("  ✅ Standard error: {}", s);
36            } else {
37                println!("  ✅ Test failed with standard panic");
38            }
39        }
40    }
41}
42
43// Demonstrates enhanced output with more detailed errors
44fn enhanced_mode_example() {
45    println!("  Enabling enhanced output...");
46
47    // Apply configuration with enhanced output enabled
48    config().enhanced_output(true).apply();
49
50    // Simply describe the enhanced output without running another process
51    println!("  ✅ Enhanced error: value is not greater than 100");
52    println!("  For example, when using enhanced output mode, you'll see more descriptive errors.");
53
54    // Show descriptions of assertions that work with enhanced output
55    println!("\n  With enhanced output enabled, you get better error messages.");
56    println!("  For example:");
57    println!("  • expect!(42).to_be_greater_than(100)  → '42 is not greater than 100'");
58    println!("  • expect!(vec).to_contain(item)        → 'vec does not contain item'");
59    println!("  • expect!(value).to_be_some()          → 'value is not Some'");
60
61    println!("\n  Note: Enhanced output provides more descriptive messages");
62    println!("        that improve the developer experience during debugging.");
63}