Assumptions and Conditional Test execution, ignoring in JUnit

Sometime you want to ignore some test depends on environment settings. Now both JUnit 4 and JUnit 5 support the concept of assumptions.

Unit Test like this:

1
2
3
4
5
6
7
@Test
public void testRun() {

Assume.assumeTrue(BooleanUtils.toBoolean(System.getProperty("runtest")));

// Rest of testcase
}

With Gradle, pass in parameter like this:

1
$ gradle test -Pruntest=false

References

Making VSCode like IntelliJ after line commented the cursor automatically moved to next line

Want to make VSCode key bindings as closed as IntelliJ key bindings like.

Firstly, install VSCode extension macros.

macros

Open Code -> Preferences -> Settings. Add following configuration into User Settings.

1
2
3
4
5
6
"macros": {
"commentLine": [
"editor.action.commentLine",
"cursorDown"
]
}

User Settings

Open Code -> Preferences -> Keyboard Shortcuts. Add following configuration into keybindings.json file.

1
2
3
4
5
6
7
8
// Place your key bindings in this file to overwrite the defaults
[
{
"key": "cmd+/",
"command": "macros.commentLine",
"when": "editorTextFocus && !editorReadonly"
}
]

keybindings.json

That’s newly added Toggle Line Comment looks like after the change:

Toggle Line Comment

Take over Mac OS X Bluetooth Control

Bluetooth on Mac OS X

Quite annoying when Bluetooth on Mac OS X is off, you can’t turn it on manually via Systme Preferences interface. Now you can install blueutil from https://github.com/toy/blueutil to solve this issue.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
igloo:cheatsheets root# blueutil --help
blueutil v2.1.0

Usage:
blueutil [options]

Without options outputs current state

-p, --power output power state as 1 or 0
-p, --power STATE set power state
-d, --discoverable output discoverable state as 1 or 0
-d, --discoverable STATE set discoverable state

-h, --help this help
-v, --version show version

STATE can be one of: 1, on, 0, off, toggle

Firstly, turn off Bluetooth service via command line:

1
2
igloo:cheatsheets root# blueutil -p 0
igloo:cheatsheets root# blueutil -d 0

Then turn on Bluetooth service via command line:

1
2
igloo:cheatsheets root# blueutil -d 1
igloo:cheatsheets root# blueutil -p 1

Setup and run DEVHINTS.IO cheatsheets on localhost

This is a static website based on Jekyll framework https://jekyllrb.com/. Need install Jekyll and .

Login as user “root” due to write permission required into /Library/Ruby/Gems directory. Install bundler and Jekyll at first:

1
igloo:cheatsheets root# gem install bundler jekyll

Then install all this application dependent libraries:

1
igloo:cheatsheets root# bundler install

Start up Jekyll website on localhost, with user “terrence” this time:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
terrence@igloo ~/Projects/cheatsheets (master ☡=)
17:28:56 𝜆 bundle exec jekyll serve --incremental
Configuration file: /Users/terrence/Projects/cheatsheets/_config.yml
Source: /Users/terrence/Projects/cheatsheets
Destination: /Users/terrence/Projects/cheatsheets/_site
Incremental build: enabled
Generating...
DEPRECATION WARNING on line 83, column 12 of /Users/terrence/Projects/cheatsheets/_sass/vendor/modularscale/_modularscale.scss:
Unescaped multiline strings are deprecated and will be removed in a future version of Sass.
To include a newline in a string, use "\a" or "\a " as in CSS.

done in 3.163 seconds.
Auto-regeneration: enabled for '/Users/terrence/Projects/cheatsheets'
Server address: http://127.0.0.1:4000
Server running... press ctrl-c to stop.

Go to URL: http://127.0.0.1:4000 start searching and using cheatsheets in localhost environment:

DEVHINTS.IO - cheatsheets

DEVHINTS.IO - cheatsheets

To generate static web content ONLY:

1
2
3
4
5
6
7
8
9
10
11
12
13
terrence@igloo ~/Projects/cheatsheets (master ☡=)
17:28:56 𝜆 bundle exec jekyll build
Configuration file: /Users/terrence/Projects/cheatsheets/_config.yml
Source: /Users/terrence/Projects/cheatsheets
Destination: ../terrencemiao.github.io/cheatsheets
Incremental build: disabled. Enable with --incremental
Generating...
DEPRECATION WARNING on line 83, column 12 of /Users/terrence/Projects/cheatsheets/_sass/vendor/modularscale/_modularscale.scss:
Unescaped multiline strings are deprecated and will be removed in a future version of Sass.
To include a newline in a string, use "\a" or "\a " as in CSS.

done in 43.269 seconds.
Auto-regeneration: disabled. Use --watch to enable.

Then can upload published website content from ../terrencemiao.github.io/cheatsheets directory to https://terrencemiao.github.io.

The Evolution of Mobile Phones

Bigger and bigger screen, fewer and fewer buttons, more and more entertaining, less and less thinking.

屏幕越来越大,按键越来越少。
娱乐越来越多,思考越来越少。

The Evolution of Mobile Phones