How to run only one unit test class using Gradle

To run a single test class Airborn’s answer is good. With using some command line options, which found here, you can simply do something like this. From version 1.10 of gradle it supports selecting tests, using a test filter. For example, For multi-flavor environments (a common use-case for Android), check this answer, as the –tests argument will be unsupported and … Read more

How can I test that a variable is more than eight characters in PowerShell?

Use the length property of the [String] type: Please note that you have to use -gt instead of > in your if condition. PowerShell uses the following comparison operators to compare values and test conditions: -eq = equals (==) -ne = not equals (!=) -lt = less than (<) -gt = greater than (>) -le = less than or equals (<=) -ge = greater than or equals (>=)

Verify a method call using Moq

You’re checking the wrong method. Moq requires that you Setup (and then optionally Verify) the method in the dependency class. You should be doing something more like this: In other words, you are verifying that calling MyClass#MyMethod, your class will definitely call SomeClass#DoSomething once in that process. Note that you don’t need the Times argument; I was just demonstrating its … Read more

How to measure test coverage in Go

Note that Go 1.2 (Q4 2013, rc1 is available) will now display test coverage results: One major new feature of go test is that it can now compute and, with help from a new, separately installed “go tool cover” program, display test coverage results. The cover tool is part of the go.tools subrepository. It can be installed by running The cover tool does two things. … Read more

What’s the difference between a mock & stub?

Stub I believe the biggest distinction is that a stub you have already written with predetermined behavior. So you would have a class that implements the dependency (abstract class or interface most likely) you are faking for testing purposes and the methods would just be stubbed out with set responses. They would not do anything … Read more

How can I time a code segment for testing performance with Pythons timeit?

You can use time.time() or time.clock() before and after the block you want to time. This method is not as exact as timeit (it does not average several runs) but it is straightforward. time.time() (in Windows and Linux) and time.clock() (in Linux) are not precise enough for fast functions (you get total = 0). In this case or if you want to average the … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)