Runing test from jar with Junit5

java -jar junit-platform-console-standalone-1.3.0-M1.jar -n .*IT -scan-class-path -cp target\test-classes\(test.jar) -cp target\app-jar-with-dependencies.jar
where:
  • -n .*IT is a regex looking for files suffixed with IT (default: ^(Test.*|.+[.$]Test.*|.*Tests?)$)
  • -scan-class-path look for tests on classpath
  • -cp: the classpath

Bonus:

to compile test classes:  mvn test-compile compile

to create test jar:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jar-plugin</artifactId>
    <version>3.1.0</version>
    <executions>
        <execution>
            <goals>
                <goal>test-jar</goal>
            </goals>
        </execution>
    </executions>
</plugin>

AWK useful commands

  1. print column n using a separator #awk -F# ‘{print $n}’
  2. print column 3 of lines that start with a number.: awk ‘/^[0-9]/ {print $3}’
  3. Variables:
    • NF: number of fields
    • NR: Number of record being processed
      • Avoid first record(row) and print last field (columnd): awk ‘{if(NR>1) print $NF}’: 

More about built-in variables: 8 Powerful Awk Built-in Variables

Some more tricks: https://twitter.com/b0rk/status/1000604334026055681

Hamcrest matchers

  • Hamcrest collections:
    • Package: org.hamcrest.collection
      • Javadoc: http://hamcrest.org/JavaHamcrest/javadoc/1.3/org/hamcrest/collection/package-summary.html
      • Check not empty collections:
assertThat(someCollection, not(IsEmptyCollection.empty()));
  • Pacakge: org.hamcrest.core:
    • IsCollectionContaining.hasItem:
assertThat(list, hasItem(item));

 

Creating new Hyperledger Fabric material and other commands

Create crypto-material:

cryptogen generate –config=./crypto-config.yaml –output=”output-folder”

Create genesys block:

configtxgen -profile TwoOrgsOrdererGenesis -outputBlock ./test-channel-artifacts/genesis.block

Create channel configuration file:

configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./test-channel-artifacts/channelTest.tx -channelID channelTest

 

Useful vi commands

https://www.cs.colostate.edu/helpdocs/vi.html

  • 0 (zero), $: cursor to start of the line, cursor to end of the line
  • w, b: beggining of next word, beginning of preceding word
  • :n (where n is a number) or nG: move cursor to line n
  • :$ or G: Move cursor to last line
  • ^f,^b: move forward / backwards one screen
  • ^d, ^u: move down (forward)/up (back) one half screen
  • u: undo
  • yy: copy line
  • Nyy: copy the next N lines
  • p: paste

 

* x delete single character under cursor
Nx delete N characters, starting with character under cursor
dw delete the single word beginning with character under cursor
dNw delete N words beginning with character under cursor;
e.g., d5w deletes 5 words
D delete the remainder of the line, starting with current cursor position
* dd delete entire current line
Ndd or dNd delete N lines, beginning with the current line;
e.g., 5dd deletes 5 lines