This repository has been archived by the owner on Feb 4, 2023. It is now read-only.
forked from linsolas/casperjs-runner-maven-plugin
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from netceler/master
New option to save log of each CasperJS invocation
- Loading branch information
Showing
11 changed files
with
275 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
invoker.goals=test | ||
invoker.failureBehavior=fail-at-end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>com.github.casperjs</groupId> | ||
<artifactId>logs</artifactId> | ||
<version>1.0</version> | ||
<packaging>pom</packaging> | ||
|
||
<name>CasperJS Runner :: Logs</name> | ||
|
||
<url>no-url</url> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<casperjs.verbose>true</casperjs.verbose> | ||
</properties> | ||
|
||
<build> | ||
|
||
<pluginManagement> | ||
<plugins> | ||
<plugin> | ||
<groupId>com.github.casperjs</groupId> | ||
<artifactId>casperjs-runner-maven-plugin</artifactId> | ||
<version>@pom.version@</version> | ||
</plugin> | ||
</plugins> | ||
</pluginManagement> | ||
|
||
<plugins> | ||
<plugin> | ||
<groupId>com.github.casperjs</groupId> | ||
<artifactId>casperjs-runner-maven-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>test</id> | ||
<goals> | ||
<goal>test</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
<configuration> | ||
<enableLogReports>true</enableLogReports> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
|
||
</build> | ||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
file = new File(basedir, 'build.log'); | ||
assert file.exists(); | ||
assert file.text.contains('casperjs-runner-maven-plugin'); | ||
assert file.text.contains('Execution of test test.js'); | ||
assert file.text.contains('Execution of test test.coffee'); | ||
assert file.text.contains('PASS 2 tests executed'); | ||
assert file.text.contains('2 passed, 0 failed'); | ||
assert file.text.contains('Tests run: 4, Success: 4 Failures: 0. Time elapsed:'); | ||
|
||
file = new File(basedir, 'target/casperjs-reports/test_coffee.txt'); | ||
assert file.exists(); | ||
assert file.text.contains('Fake coffee test'); | ||
|
||
file = new File(basedir, 'target/casperjs-reports/test_js.txt'); | ||
assert file.exists(); | ||
assert file.text.contains('Fake js test'); | ||
|
||
file = new File(basedir, 'target/casperjs-reports/subdir_test_coffee.txt'); | ||
assert file.exists(); | ||
assert file.text.contains('Subdir fake coffee test'); | ||
|
||
file = new File(basedir, 'target/casperjs-reports/subdir_test_js.txt'); | ||
assert file.exists(); | ||
assert file.text.contains('Subdir fake js test'); | ||
|
||
return true; |
4 changes: 4 additions & 0 deletions
4
src/it/casperjs-runner/logs/src/test/casperjs/subdir/test.coffee
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
casper.test.begin 'Subdir fake coffee test', 2, (test) -> | ||
test.assert true, 'true is so true' | ||
test.assertNot false, 'false is so wrong' | ||
test.done() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
casper.test.begin('Subdir fake js test', 2, function(test) { | ||
test.assert(true, 'true is so true'); | ||
test.assertNot(false, 'false is so wrong'); | ||
test.done(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
casper.test.begin 'Fake coffee test', 2, (test) -> | ||
test.assert true, 'true is so true' | ||
test.assertNot false, 'false is so wrong' | ||
test.done() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
casper.test.begin('Fake js test', 2, function(test) { | ||
test.assert(true, 'true is so true'); | ||
test.assertNot(false, 'false is so wrong'); | ||
test.done(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
src/main/java/com/github/casperjs/casperjsrunner/CloneOutputStream.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package com.github.casperjs.casperjsrunner; | ||
|
||
import static com.google.common.collect.Lists.newArrayList; | ||
|
||
import java.io.IOException; | ||
import java.io.OutputStream; | ||
import java.util.List; | ||
|
||
public class CloneOutputStream extends OutputStream { | ||
|
||
private List<OutputStream> streams; | ||
|
||
public CloneOutputStream(final OutputStream... streams) { | ||
this.streams = newArrayList(streams); | ||
} | ||
|
||
@Override | ||
public void write(final int b) throws IOException { | ||
for (final OutputStream stream : streams) { | ||
stream.write(b); | ||
} | ||
} | ||
|
||
@Override | ||
public void write(final byte[] b) throws IOException { | ||
for (final OutputStream stream : streams) { | ||
stream.write(b); | ||
} | ||
} | ||
|
||
@Override | ||
public void write(final byte[] b, final int off, final int len) throws IOException { | ||
for (final OutputStream stream : streams) { | ||
stream.write(b, off, len); | ||
} | ||
} | ||
|
||
@Override | ||
public void flush() throws IOException { | ||
for (final OutputStream stream : streams) { | ||
stream.flush(); | ||
} | ||
} | ||
|
||
@Override | ||
public void close() throws IOException { | ||
for (final OutputStream stream : streams) { | ||
stream.close(); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
src/test/java/com/github/casperjs/casperjsrunner/CloneOutputStreamTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
package com.github.casperjs.casperjsrunner; | ||
|
||
import static org.mockito.Mockito.verify; | ||
import static org.mockito.Mockito.verifyNoMoreInteractions; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.mockito.Mock; | ||
import org.mockito.runners.MockitoJUnitRunner; | ||
|
||
import java.io.IOException; | ||
import java.io.OutputStream; | ||
|
||
@RunWith(MockitoJUnitRunner.class) | ||
public class CloneOutputStreamTest { | ||
|
||
@Mock | ||
private OutputStream out1; | ||
|
||
@Mock | ||
private OutputStream out2; | ||
|
||
private CloneOutputStream stream; | ||
|
||
@Before | ||
public void initializeStream() { | ||
stream = new CloneOutputStream(out1, out2); | ||
} | ||
|
||
@Test | ||
public void testWriteInt() throws IOException { | ||
final int b = 5; | ||
|
||
stream.write(b); | ||
|
||
verify(out1).write(b); | ||
verify(out2).write(b); | ||
verifyNoMoreInteractions(out1, out2); | ||
} | ||
|
||
@Test | ||
public void testWriteByteArray() throws IOException { | ||
final byte[] b = new byte[] { 1, 2, 3 }; | ||
|
||
stream.write(b); | ||
|
||
verify(out1).write(b); | ||
verify(out2).write(b); | ||
verifyNoMoreInteractions(out1, out2); | ||
} | ||
|
||
@Test | ||
public void testWriteByteArrayIntInt() throws IOException { | ||
final byte[] b = new byte[] { -1, -2, -3 }; | ||
final int off = 4; | ||
final int len = 3; | ||
|
||
stream.write(b, off, len); | ||
|
||
verify(out1).write(b, off, len); | ||
verify(out2).write(b, off, len); | ||
verifyNoMoreInteractions(out1, out2); | ||
} | ||
|
||
@Test | ||
public void testFlush() throws IOException { | ||
stream.flush(); | ||
|
||
verify(out1).flush(); | ||
verify(out2).flush(); | ||
verifyNoMoreInteractions(out1, out2); | ||
} | ||
|
||
@Test | ||
public void testClose() throws IOException { | ||
stream.close(); | ||
|
||
verify(out1).close(); | ||
verify(out2).close(); | ||
verifyNoMoreInteractions(out1, out2); | ||
} | ||
|
||
} |