标签: testcase

凸壳的测试用例数据

我需要为类赋值创建一个2D凸包函数,我想要一个比赋值更强大的测试用例.有没有人知道一个大的测试案例(25 <n <100)的解决方案?

geometry convex-hull testcase

5
推荐指数
1
解决办法
6256
查看次数

在TestCase中启动第二个活动(这不是被测活动)

如何在ActivityInstrumentationTestCase2或InstrumentationTestCase中启动第二个(模拟)活动?

我的问题是:

Intent intent = new Intent(getInstrumentation().getContext(), MyMock.class);
myMock = (MyMock) getInstrumentation().startActivitySync(intent);
Run Code Online (Sandbox Code Playgroud)

...导致错误"意图正在进行...解决到不同的过程...测试".对Intent使用getTargetContext()导致"无法解析Intent的活动",因为我的mock类不是app包的一部分.

08-07 19:38:25.822: INFO/TestRunner(2656): ----- begin exception -----
08-07 19:38:25.822: INFO/TestRunner(2656): java.lang.RuntimeException: Unable to resolve activity for: Intent { cmp=com.cocktails/.test.recipes.RecipeBookMock }
08-07 19:38:25.822: INFO/TestRunner(2656):     at android.app.Instrumentation.startActivitySync(Instrumentation.java:447)
08-07 19:38:25.822: INFO/TestRunner(2656):     at com.cocktails.test.recipes.RecipeUpdaterTest.testNewRecipe(RecipeUpdaterTest.java:55)
08-07 19:38:25.822: INFO/TestRunner(2656):     at java.lang.reflect.Method.invokeNative(Native Method)
08-07 19:38:25.822: INFO/TestRunner(2656):     at java.lang.reflect.Method.invoke(Method.java:521)
08-07 19:38:25.822: INFO/TestRunner(2656):     at android.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:191)
08-07 19:38:25.822: INFO/TestRunner(2656):     at android.test.InstrumentationTestCase.runTest(InstrumentationTestCase.java:181)
08-07 19:38:25.822: INFO/TestRunner(2656):     at junit.framework.TestCase.runBare(TestCase.java:127)
08-07 19:38:25.822: INFO/TestRunner(2656):     at junit.framework.TestResult$1.protect(TestResult.java:106)
08-07 19:38:25.822: INFO/TestRunner(2656):     at junit.framework.TestResult.runProtected(TestResult.java:124)
08-07 …
Run Code Online (Sandbox Code Playgroud)

instrumentation android mocking testcase android-activity

5
推荐指数
1
解决办法
1892
查看次数

如何在grails testcase中使用executeQuery?

如何在grails testcase中使用executeQuery?

A error : groovy.lang.MissingMethodException: No signature of method ***.executeQuery() is applicable for argument types: () values: []
Run Code Online (Sandbox Code Playgroud)

我已经调用了mockDomain.

顺便说一句,它是在单元测试中.

谢谢!

grails testcase

5
推荐指数
2
解决办法
3868
查看次数

在TFS API中将测试用例添加到ITestSuiteBase

我正在使用TFS API并遇到了ITestSuiteBase和IRequirementTestSuite的问题.我已经马上在IStaticTestSuite中轻松创建一个新的测试用例:

IStaticTestSuite workingSuite = this.WorkingSuite as IStaticTestSuite;
testCase = CreateTestCase(this.TestProject, tci.Title, tci.Description);
workingSuite.Entries.Add(testCase);
this.Plan.Save();
Run Code Online (Sandbox Code Playgroud)

但是,此解决方案不适用于需求测试套件或ITestSuiteBase.我认为可行的方法是:

ITestcase testCase = null;
testCase = CreateTestCase(this.TestProject, tci.Title, tci.Description);
this.WorkingSuite.AllTestCases.Add(testCase);
this.WorkingSuite.TestCases.Add(testCase);
this.Plan.Save();
Run Code Online (Sandbox Code Playgroud)

但是这种方法实际上并没有将测试用例添加到套件中.但是,它确实将测试用例添加到计划中.我可以查询创建的测试用例,但它没有按预期显示在套件中 - 即使在代码之后也是如此.刷新工作套房没有任何好处.

其他代码如下:

    public static ITestCase CreateTestCase(ITestManagementTeamProject project, string title, string desc = "", TeamFoundationIdentity owner = null)
    {
        // Create a test case.
        ITestCase testCase = project.TestCases.Create();
        testCase.Owner = owner;
        testCase.Title = title;
        testCase.Description = desc;
        testCase.Save();
        return testCase;
    }
Run Code Online (Sandbox Code Playgroud)

有没有人能够成功地将测试用例添加到需求测试套件或ITestSuiteBase中?

c# tfs test-suite testcase visual-studio-2013

5
推荐指数
1
解决办法
3057
查看次数

我们可以在 xcode 中以编程方式设置性能测试用例基线吗?

我在我的项目中使用 XCTest 框架编写了一些性能测试用例。我想知道是否可以在第一次运行之前以编程方式为性能测试设置基线值,或者除了性能结果窗口之外,还有其他方法可以设置基线。

xcode performance-testing baseline testcase xctest

5
推荐指数
1
解决办法
825
查看次数

注释/获取/映射 Testrail 测试用例 ID 到本地 Java TestNG 测试(Jenkins Test Rail 集成)

我正在尝试使用 Testrail 作为测试用例管理系统,因此,将 testrail 与 Jenkins 集成会很有用。

这就是我想要实现的目标:

假设我在 testrail 中手动创建了三个测试用例,用例 ID 为 C1、C2 和 C3,这些测试用例将具有一些独特的自动化测试名称,例如 A1、A2 和 A3(在更多信息中,testrail 中将有一个字段如此独特的信息)

当我点击“开始自动化测试”按钮并从 testrail 运行 Jenkins 作业时(考虑到我已经为具有此按钮的 testrail 实现了 UI 脚本):

界面脚本输出

,我想运行一个脚本/东西,它采用所选测试用例的用例 ID,并将这些 ID 临时注释到实际的 Java 测试中,以便它可以运行那些特定的测试并将结果发布回 Testrail。

我能想到的方法:

当我点击 Testrail 上的“开始自动化测试”按钮时,我可以创建一个脚本来运行以创建一个 XML 文件,该文件将包含来自 Testrail 的所需的选定测试用例。然后,此 XML 将作为 Jenkins 作业的默认输入提供,它将运行 XML 文件中提到的测试用例。此 XML 将是临时的,每次从 Testrail 进行选择时都会被替换。但是,你怎么做呢?我是 Testrail 的新手并阅读了它的 API,看起来 API 将有助于将结果发布回 Testrail。但是,我们如何实现 ID 的映射?

此外,任何关于将结果发布回 Testrail 的建议都会很有用。

testcase jenkins jenkins-plugins testrail jenkins-workflow

5
推荐指数
1
解决办法
3703
查看次数

在单元测试时快速获取UITableView中的数字行?

我正在编写一个UIViewController具有UITableView 的测试用例.我想问一下如何在UITableView中获取行数

 func testloadingDataIntoUiTableView()
    {      
      var  countRow:Int =  viewController.formListTableView.numberOfRowsInSection   
      XCTAssert(countRow == 4)  
    }
Run Code Online (Sandbox Code Playgroud)

count uitableview testcase swift

5
推荐指数
1
解决办法
7026
查看次数

从控制台运行参数化测试

我想只使用测试用例中的一组参数运行测试方法。

我正在使用 NUnit 控制台 3.4.1。

代码示例:

[Category("SmokeTests")]
[TestCase("1 param", "2 param", "3 param")]
[TestCase("aaa", "bbb", "ccc")]
public void TestMethod(string a, string b, string c)
{
    // do something
}
Run Code Online (Sandbox Code Playgroud)

要运行的命令行:

nunit3-console.exe UiTests.dll --where "cat==SmokeTests and name==TestMethod(\"aaa\", \"bbb\", \"ccc\")" --result C:\temp\result.xml
Run Code Online (Sandbox Code Playgroud)

当前 NUnit 返回错误

选择表达式中位置 50 处出现意外标记“(”。

c# unit-testing nunit-console testcase nunit-3.0

5
推荐指数
1
解决办法
115
查看次数

Django 单元测试在登录时提供匿名用户

我有以下用于 Django 登录单元测试的代码。

"""This is the unit test case for form element"""
from django.test import TestCase
from django.contrib.auth.models import User


class TestForm(TestCase):
    def setUp(self):
        self.credentials = {
            'username': 'abhishek',
            'password': 'Abhishek@12345'}
        User.objects.create_user(**self.credentials)

    def test_login(self):
        # send login data
        response = self.client.post('/accounts/login', self.credentials, follow=True)
        # should be logged in now
        print(response.context['user'])
        self.assertTrue(response.context['user'].is_authenticated)
Run Code Online (Sandbox Code Playgroud)

当我通过我的命令 python ../manage.py test accounts.tests.test_form.TestForm 执行这个单元测试时,它给出了以下错误。

Creating test database for alias 'default'...
System check identified no issues (0 silenced).
AnonymousUser
F
======================================================================
FAIL: test_login (accounts.tests.test_form.TestForm)
----------------------------------------------------------------------
Traceback (most recent …
Run Code Online (Sandbox Code Playgroud)

python django unit-testing testcase

5
推荐指数
1
解决办法
697
查看次数

Laravel PHPUnit 返回 404

对于laravel API,我已经编写了测试用例。但是每当我运行测试用例时,它总是因以下错误而失败,

1) Tests\Feature\CompanyTest::orgTest
Expected status code 200 but received 404.
Failed asserting that 200 is identical to 404.
Run Code Online (Sandbox Code Playgroud)

添加$this->withoutExceptionHandling();到测试用例代码后,它返回以下错误,

1) Tests\Feature\CompanyTest::orgTest
Symfony\Component\HttpKernel\Exception\NotFoundHttpException: POST domainname/index.php/api/company

/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithExceptionHandling.php:126
/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:415
/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:113
/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php:507
/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php:473
/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php:332
/tests/Feature/CompanyTest.php:21
Run Code Online (Sandbox Code Playgroud)

我在测试文件中的代码是,

public function orgTest()
    {
        $requestData = ["organizationId" => 10,"offset"=>1,"limit"=>10,"notificationId"=>""];
        $response = $this->withoutExceptionHandling();
        $response->postJson('/index.php/api/company',$requestData);
        $response->assertStatus(200);
    }
Run Code Online (Sandbox Code Playgroud)

我用谷歌搜索了错误并尝试了许多解决方案但无法成功。任何人请让我知道是什么问题。

php phpunit testcase laravel laravel-7.x

5
推荐指数
1
解决办法
642
查看次数