Add colors and summary to test report
This commit is contained in:
parent
aa1b47c596
commit
926a6c1849
11
Cargo.lock
generated
11
Cargo.lock
generated
@ -220,6 +220,16 @@ version = "1.0.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422"
|
checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "colored"
|
||||||
|
version = "2.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "cbf2150cce219b664a8a70df7a1f933836724b503f8a413af9365b4dcc4d90b8"
|
||||||
|
dependencies = [
|
||||||
|
"lazy_static",
|
||||||
|
"windows-sys 0.48.0",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "console"
|
name = "console"
|
||||||
version = "0.15.8"
|
version = "0.15.8"
|
||||||
@ -756,6 +766,7 @@ dependencies = [
|
|||||||
"cheap-ruler",
|
"cheap-ruler",
|
||||||
"chksum-md5",
|
"chksum-md5",
|
||||||
"clap",
|
"clap",
|
||||||
|
"colored",
|
||||||
"cucumber",
|
"cucumber",
|
||||||
"futures",
|
"futures",
|
||||||
"geo-types",
|
"geo-types",
|
||||||
|
@ -7,6 +7,7 @@ edition = "2021"
|
|||||||
cheap-ruler = "0.4.0"
|
cheap-ruler = "0.4.0"
|
||||||
chksum-md5 = "0.0.0"
|
chksum-md5 = "0.0.0"
|
||||||
clap = "4.5.4"
|
clap = "4.5.4"
|
||||||
|
colored = "2.1.0"
|
||||||
cucumber = { version = "0.21.0", features = ["tracing"] }
|
cucumber = { version = "0.21.0", features = ["tracing"] }
|
||||||
futures = "0.3.30"
|
futures = "0.3.30"
|
||||||
geo-types = "0.7.13"
|
geo-types = "0.7.13"
|
||||||
|
@ -1,38 +1,87 @@
|
|||||||
|
use colored::Colorize;
|
||||||
|
use cucumber::{cli, event, parser, Event};
|
||||||
use std::io::{self, Write};
|
use std::io::{self, Write};
|
||||||
|
|
||||||
use cucumber::{cli, event, parser, Event};
|
#[derive(Debug, Default)]
|
||||||
// TODO: add colors
|
pub struct DotWriter {
|
||||||
// TODO: print summary at the end
|
scenarios_started: usize,
|
||||||
pub struct DotWriter;
|
scenarios_failed: usize,
|
||||||
|
scenarios_finished: usize,
|
||||||
|
features_started: usize,
|
||||||
|
features_finished: usize,
|
||||||
|
step_started: usize,
|
||||||
|
step_failed: usize,
|
||||||
|
step_passed: usize,
|
||||||
|
step_skipped: usize,
|
||||||
|
// TODO: add timestamp to report timing
|
||||||
|
}
|
||||||
|
|
||||||
impl<W: 'static> cucumber::Writer<W> for DotWriter {
|
impl<W: 'static> cucumber::Writer<W> for DotWriter {
|
||||||
type Cli = cli::Empty; // we provide no CLI options
|
type Cli = cli::Empty; // we provide no CLI options
|
||||||
|
|
||||||
async fn handle_event(&mut self, ev: parser::Result<Event<event::Cucumber<W>>>, _: &Self::Cli) {
|
async fn handle_event(&mut self, ev: parser::Result<Event<event::Cucumber<W>>>, _: &Self::Cli) {
|
||||||
|
let green_dot = ".".green();
|
||||||
|
let cyan_dash = "-".cyan();
|
||||||
|
let red_cross = "X".red();
|
||||||
match ev {
|
match ev {
|
||||||
Ok(Event { value, .. }) => match value {
|
Ok(Event { value, .. }) => match value {
|
||||||
event::Cucumber::Feature(_feature, ev) => match ev {
|
event::Cucumber::Feature(_feature, ev) => match ev {
|
||||||
event::Feature::Started => {
|
event::Feature::Started => {
|
||||||
print!(".")
|
self.features_started += 1;
|
||||||
|
print!("{green_dot}")
|
||||||
}
|
}
|
||||||
event::Feature::Scenario(_scenario, ev) => match ev.event {
|
event::Feature::Scenario(_scenario, ev) => match ev.event {
|
||||||
event::Scenario::Started => {
|
event::Scenario::Started => {
|
||||||
print!(".")
|
self.scenarios_started += 1;
|
||||||
|
print!("{green_dot}")
|
||||||
}
|
}
|
||||||
event::Scenario::Step(_step, ev) => match ev {
|
event::Scenario::Step(_step, ev) => match ev {
|
||||||
event::Step::Started => {
|
event::Step::Started => {
|
||||||
print!(".")
|
self.step_started += 1;
|
||||||
|
print!("{green_dot}")
|
||||||
|
}
|
||||||
|
event::Step::Passed(..) => {
|
||||||
|
self.step_passed += 1;
|
||||||
|
print!("{green_dot}")
|
||||||
|
}
|
||||||
|
event::Step::Skipped => {
|
||||||
|
self.step_skipped += 1;
|
||||||
|
print!("{cyan_dash}")
|
||||||
}
|
}
|
||||||
event::Step::Passed(..) => print!("."),
|
|
||||||
event::Step::Skipped => print!("-"),
|
|
||||||
event::Step::Failed(_, _, _, _err) => {
|
event::Step::Failed(_, _, _, _err) => {
|
||||||
print!("x")
|
self.step_failed += 1;
|
||||||
|
print!("{red_cross}")
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
_ => {}
|
event::Scenario::Hook(_, _) => {}
|
||||||
|
event::Scenario::Background(_, _) => {}
|
||||||
|
event::Scenario::Log(_) => {}
|
||||||
|
event::Scenario::Finished => {
|
||||||
|
self.scenarios_finished += 1;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
_ => {}
|
event::Feature::Rule(_, _) => {}
|
||||||
|
event::Feature::Finished => {
|
||||||
|
self.features_finished += 1;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
event::Cucumber::Finished => {
|
||||||
|
println!();
|
||||||
|
let f = format!("{} failed", self.scenarios_failed).red();
|
||||||
|
let p = format!("{} passed", self.scenarios_finished).green();
|
||||||
|
println!("{} scenarios ({f}, {p})", self.scenarios_started);
|
||||||
|
let f = format!("{} failed", self.step_failed).red();
|
||||||
|
let s = format!("{} skipped", self.step_skipped).cyan();
|
||||||
|
let p = format!("{} passed", self.step_passed).green();
|
||||||
|
println!("{} steps ({f}, {s}, {p})", self.step_started);
|
||||||
|
}
|
||||||
|
event::Cucumber::ParsingFinished {
|
||||||
|
features: _,
|
||||||
|
rules: _,
|
||||||
|
scenarios: _,
|
||||||
|
steps: _,
|
||||||
|
parser_errors: _,
|
||||||
|
} => {}
|
||||||
_ => {}
|
_ => {}
|
||||||
},
|
},
|
||||||
Err(e) => println!("Error: {e}"),
|
Err(e) => println!("Error: {e}"),
|
||||||
|
Loading…
Reference in New Issue
Block a user