What is the difference between smoke testing and sanity testing?

Sanity testing Sanity testing is the subset of regression testing and it is performed when we do not have enough time for doing testing. Sanity testing is the surface level testing where QA engineer verifies that all the menus, functions, commands available in the product and project are working fine. Example For example, in a … Read more

Getting Unknown Provider error when injecting a Service into an Angular unit test

I just ran into this and solved it by switching to getting the service using the $injector explicitly: var EventingService, $rootScope; beforeEach(inject(function($injector) { EventingService = $injector.get(‘EventingService’); $rootScope = $injector.get(‘$rootScope’); })); I wish I could tell you why this works and why the simple beforeEach(inject(function(EventingService) { …. })); does not, but I don’t have the time … Read more

How can I test stdin and stdout?

Use dependency injection. Coupling it with generics and monomorphism, you don’t lose any performance: use std::io::{self, BufRead, Write}; fn prompt<R, W>(mut reader: R, mut writer: W, question: &str) -> String where R: BufRead, W: Write, { write!(&mut writer, “{}”, question).expect(“Unable to write”); let mut s = String::new(); reader.read_line(&mut s).expect(“Unable to read”); s } #[test] fn … Read more

What is an idiomatic way to have shared utility functions for integration tests and benchmarks?

Create a shared crate (preferred) As stated in the comments, create a new crate. You don’t have to publish the crate to crates.io. Just keep it as a local unpublished crate inside your project and mark it as a development-only dependency. This is best used with version 2 of the Cargo resolver. For better performance, … Read more

How to test a function’s output (stdout/stderr) in unit tests

One thing to also remember, there’s nothing stopping you from writing functions to avoid the boilerplate. For example I have a command line app that uses log and I wrote this function: func captureOutput(f func()) string { var buf bytes.Buffer log.SetOutput(&buf) f() log.SetOutput(os.Stderr) return buf.String() } Then used it like this: output := captureOutput(func() { … Read more