English 中文(简体)
我是否能够从指挥线对Grails项目进行单一单位测试?
原标题:Can I run a single unit test from the command line for a Grails project?

我先通过打字<代码>grails test-app:unit<<>>>/code>进行我的铁路单位测试,操作所有单位测试。 是否有办法规定单一检验标准?

<><>Edit>: 到目前为止,每个人都基本上说了同样的事情,但当我这样做时,没有进行试验。 是否还有其他想法?

http://www.hchr.org。 在大韩民国,我使用的是测试类别的名称,而不是正在测试的类别的名称。 一俟我尝试而不是Foo Tests,就完全有效。

最佳回答

www.un.org/Depts/DGACM/index_spanish.htm 贵机构可能错的事务:

  • 你的命令是不正确的。 我的工作是:

    grails test-app-unit Foo(在我的测试类别为时) Foo 试验s.groovy

  • 页: 1

    我在承认我的检验时遇到一些问题。 当我延长<条码> Groovy TestCase时,事情似乎正常进行。

Working Example

这里有一套为我工作的试验样本。 也许你能够发现他们和你的测试之间存在一些差别?

<>说明: 所有这些都与<条码>测试 装成<>>的原始材料一起操作。

test/unit/Foo Tests.groovy

import grails.test.GrailsUnitTestCase
class FooTest extends GrailsUnitTestCase {
    void testFoo() {
        assert true
    }

    void testBar() {
        assert true
    }
}

test/unit/Bar Tests.groovy

import grails.test.GrailsUnitTestCase
class BarTest extends GrailsUnitTestCase {
    void testFoo() {
        assert true
    }

    void testBar() {
        assert true
    }
}

test/unit/my/pkg/Baz Tests.groovy

package my.pkg

import grails.test.GrailsUnitTestCase

class BazTest extends GrailsUnitTestCase {
    void testFoo() {
        assert true
    }

    void testBar() {
        assert true
    }
}

http://www.un.org。

$ grails test-app -unit
...

Starting unit test phase ...

-------------------------------------------------------
Running 6 unit tests...
Running test my.pkg.BazTest...PASSED
Running test FooTest...PASSED
Running test BarTest...PASSED
Tests Completed in 847ms ...
-------------------------------------------------------
Tests passed: 6
Tests failed: 0
-------------------------------------------------------

...
Tests PASSED - view reports in target/test-reports

<>command> Foo单位检测

$ grails test-app -unit Foo
...

Starting unit test phase ...

-------------------------------------------------------
Running 1 unit test...
Running test FooTest...PASSED
Tests Completed in 815ms ...
-------------------------------------------------------
Tests passed: 2
Tests failed: 0
-------------------------------------------------------

...
Tests PASSED - view reports in target/test-reports

command: my.pkg。 Baz单位检测

$ grails test-app -unit my.pkg.Baz
...

Starting unit test phase ...

-------------------------------------------------------
Running 2 unit tests...
Running test my.pkg.BazTest...PASSED
Tests Completed in 842ms ...
-------------------------------------------------------
Tests passed: 2
Tests failed: 0
-------------------------------------------------------

...
Tests PASSED - view reports in target/test-reports

I在铁路1.2.3和铁路1.3.4中尝试过这些铁路,两者都相同。

问题回答

grails test-app -unit YourController.testSomething

页: 1 有些是测试方法。

你应该看到这样的情况。

测验——观察报告

鉴于有一个测试班foo.Bar Tests,你可以使用以下指挥对该类别的测试进行:

grails test-app :unit foo.Bar

或者使用以下方法在该类别中操作单一测试方法:

grails test-app :unit foo.Bar.testMethod

请注意,在具体说明测试类别名称时,你不列入“试验”一词。

grails test-app -unit com.package.YourController.testSomething

在你进行测试时,你需要列入一揽子名称。

这肯定会奏效,我每天都使用它。

之后将进行单一测试

grails test-app :unit ExampleControllerTests.testName

之后将管理所有主计长办公室 测试

grails test-app :unit ExampleControllerTests




相关问题
run unit tests and coverage in certain python structure

I have some funny noob problem. I try to run unit tests from commandline: H:PROpyEstimator>python src estpython est_power_estimator.py Traceback (most recent call last): File "src est...

How to unit-test an enterprise symfony project?

I´m working on a huge project at my work. We have about 200 database tables, accordingly a huge number of Models, Actions and so on. How should I begin to write tests for this? My biggest problem ...

Code Coverage Tools & Visual Studio 2008 Pro

Just wondering what people are using for code coverage tools when using MS Visual Studio 2008 Pro. We are using the built-in MS test project and unit testing tool (the one that come pre-installed ...

Unit testing. File structure

I have a C++ legacy codebase with 10-15 applications, all sharing several components. While setting up unittests for both shared components and for applications themselves, I was wondering if there ...

Unit Testing .NET 3.5 projects using MStest in VS2010

There s a bug/feature in Visual Studio 2010 where you can t create a unit test project with the 2.0 CLR. https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=483891&wa=...

Unit Test for Exceptions Message

Is there a simple (Attribute-driven) way to have the following test fail on the message of the exception. [TestMethod()] [ExpectedException(typeof(ArgumentException))] public void ExceptionTestTest() ...