我正在为 Javascript 代码编写一些测试,当遇到错误时,我需要在编译过程中转储一些消息。
System.out.println()Javascript中是否有与Java等效的东西?
PS:我还需要在实现测试时转储调试语句。
更新
我在包含所有合并测试的文件上使用 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>
更新二
我试过了console.log("..."),但我得到:
js: "src/main/webapp/html/js/concat/tests_all.js", line 147:
uncaught JavaScript runtime exception: ReferenceError: "console" is not defined
我正在测试的代码是一组函数(如在库中)。我正在使用 QUnit。