Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

maven test class

mvn install -Dmaven.test.skip=true

# or

mvn install -DskipTests

# If -Dmaven.test.skip=true (or simply -Dmaven.test.skip) is specified, 
# the test-jars aren't built, and any module that relies on them will 
# fail its build.

# In contrast, when you use -DskipTests, Maven does not run the tests, 
# but it does compile them and build the test-jar, making it available 
# for the subsequent modules.
Comment

maven test class

# Run all the unit test classes.
$ mvn test

# Run a single test class.
$ mvn -Dtest=TestApp1 test

# Run multiple test classes.
$ mvn -Dtest=TestApp1,TestApp2 test

# Run a single test method from a test class.
$ mvn -Dtest=TestApp1#methodname test

# Run all test methods that match pattern 'testHello*' from a test class.
$ mvn -Dtest=TestApp1#testHello* test

# Run all test methods match pattern 'testHello*' and 'testMagic*' from a test class.
$ mvn -Dtest=TestApp1#testHello*+testMagic* test
Comment

maven test class

private final ByteArrayOutputStream outContent = new ByteArrayOutputStream();
private final ByteArrayOutputStream errContent = new ByteArrayOutputStream();
private final PrintStream originalOut = System.out;
private final PrintStream originalErr = System.err;

@Before
public void setUpStreams() {
    System.setOut(new PrintStream(outContent));
    System.setErr(new PrintStream(errContent));
}

@After
public void restoreStreams() {
    System.setOut(originalOut);
    System.setErr(originalErr);
}

sample test cases:

@Test
public void out() {
    System.out.print("hello");
    assertEquals("hello", outContent.toString());
}

@Test
public void err() {
    System.err.print("hello again");
    assertEquals("hello again", errContent.toString());
}
Comment

PREVIOUS NEXT
Code Example
Shell :: empty commit 
Shell :: commited to wrong branch 
Shell :: nginx.service is not active, cannot reload. 
Shell :: docker rm all containers 
Shell :: create react app typescript 
Shell :: logstash is not listening on ip address 
Shell :: install metasploitable on ubuntu 
Shell :: install xdotool ubuntu 
Shell :: list used ports on mac 
Shell :: vue-cli-service not found ubuntu 
Shell :: find php.ini ubuntu 
Shell :: powershell zip 
Shell :: npm install --no-audit --save --save-exact --loglevel error react react-dom react-scripts cra-template has failed. 
Shell :: Job for mongod.service failed because the control process exited with error code. See "systemctl status mongod.service" and "journalctl -xeu mongod.service" for details. 
Shell :: uninstall postgres brew 
Shell :: how to know fedora version 
Shell :: how to install pyqt5 on windows 
Shell :: disable ubuntu firewall 
Shell :: remove 4k video downloader ubuntu 20.04 
Shell :: conda install numpy 
Shell :: (node:14140) UnhandledPromiseRejectionWarning: Error: FFmpeg/avconv not found! 
Shell :: git delete local branch except master 
Shell :: Allow and Block Ports Using Port in ubuntu 
Shell :: add homebrew to your path 
Shell :: git unset alias 
Shell :: docker remove all untagged images 
Shell :: see apache version ubuntu 
Shell :: linux memory cache clear 
Shell :: how to delete a package in ubuntu 
Shell :: how to clone from heroku 
ADD CONTENT
Topic
Content
Source link
Name
8+3 =