【发布时间】:2012-02-02 17:27:01
【问题描述】:
我正在为 Javascript 代码编写一些测试,并且在编译过程中遇到错误时需要转储一些消息。
在 Javascript 中是否有与 Java 的 System.out.println() 等价的东西?
P.S.:我还需要在实现测试时转储调试语句。
更新
我在包含所有合并测试的文件上使用 maven 插件:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>org.mozilla.javascript.tools.shell.Main</mainClass>
<arguments>
<argument>-opt</argument>
<argument>-1</argument>
<argument>${basedir}/src/main/webapp/html/js/test/test.js</argument>
</arguments>
</configuration>
</plugin>
更新 II
我试过console.log("..."),但我得到了:
js: "src/main/webapp/html/js/concat/tests_all.js", line 147:
uncaught JavaScript runtime exception: ReferenceError: "console" is not defined
我正在测试的代码是一组函数(例如在库中)。我正在使用 QUnit。
【问题讨论】:
标签: java javascript compile-time println system.out