Testing hooks callback

Test in isolation When developing a plugin, the best way to test it is without loading the WordPress environment. If you write code that can be easily tested without WordPress, your code becomes better. Every component that is unit tested, should be tested in isolation: when you test a class, you only have to test … Read more

Proper way to assert type of variable in Python

The isinstance built-in is the preferred way if you really must, but even better is to remember Python’s motto: “it’s easier to ask forgiveness than permission”!-) (It was actually Grace Murray Hopper’s favorite motto;-). I.e.: This, BTW, lets the function work just fine on Unicode strings — without any extra effort!-)

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

You can set up a default way to shorten the command line and use it as a template for further configurations by changing the default JUnit Run/Debug Configuration template. Then all new Run/Debug configuration you create in project will use the same option. Here is the related blog post about configurable command line shortener option.

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