When should I use Debug.Assert()?

In Debugging Microsoft .NET 2.0 Applications John Robbins has a big section on assertions. His main points are: Assert liberally. You can never have too many assertions. Assertions don’t replace exceptions. Exceptions cover the things your code demands; assertions cover the things it assumes. A well-written assertion can tell you not just what happened and … Read more

Mocking USB input

Mocking usb devices using umockdev Umockdev is a linux based application which record the behaviour as well as properties of hardware and run the software independent of actual hardware it is running on. Hardware devices can be simulated in virtual environments without disturbing the whole system.It currently supports sysfs, uevents, basic support for /dev devices, … Read more

How to run golang tests sequentially?

You can’t / shouldn’t rely on test execution order. The order in which tests are executed is not defined, and with the use of testing flags it is possible to exclude tests from running, so you have no guarantee that they will run at all. For example the following command will only run tests whose … Read more

How to `go test` all tests in my project?

This should run all tests in current directory and all of its subdirectories: $ go test ./… This should run all tests for given specific directories: $ go test ./tests/… ./unit-tests/… ./my-packages/… This should run all tests with import path prefixed with foo/: $ go test foo/… This should run all tests import path prefixed … Read more

How to mock external dependencies in tests? [duplicate]

I would suggest you wrap the back-end function speed_control::increase in some trait: trait SpeedControlBackend { fn increase(); } struct RealSpeedControl; impl SpeedControlBackend for RealSpeedControl { fn increase() { speed_control::increase(); } } struct MockSpeedControl; impl SpeedControlBackend for MockSpeedControl { fn increase() { println!(“MockSpeedControl::increase called”); } } trait SpeedControl { fn other_function(&self) -> Result<(), ()>; } struct … Read more

Running multiple Selenium tests at the same time

You can run multiple instances of chromedriver locally quite easily, just instantiate multiple driver objects, chromedriver will keep the profiles separate and find a port to run on all by itself. Here a link to an example that can run multiple tests using TestNG and Maven: https://github.com/Ardesco/Selenium-Maven-Template Just clone the above project and run the … Read more

How to configure “Shorten command line” method for whole project in IntelliJ

Inside your .idea folder, change workspace.xml file Add <property name=”dynamic.classpath” value=”true” /> to <component name=”PropertiesComponent”> . . . </component> Example <component name=”PropertiesComponent”> <property name=”project.structure.last.edited” value=”Project” /> <property name=”project.structure.proportion” value=”0.0″ /> <property name=”project.structure.side.proportion” value=”0.0″ /> <property name=”settings.editor.selected.configurable” value=”preferences.pluginManager” /> <property name=”dynamic.classpath” value=”true” /> </component> If you don’t see one, feel free to add it yourself <component … Read more

How to prepare a nested data structure for a data-driven test in Karate?

I don’t recommend nesting unless absolutely necessary. You may be able to “flatten” your permutations into a single table, something like this: https://github.com/intuit/karate/issues/661#issue-402624580 That said, look out for the alternate option to Examples: which just might work for your case: https://github.com/intuit/karate#data-driven-features EDIT: In version 1.3.0, a new @setup life cycle was introduced that changes the … Read more