testcase

Django test database not auto-flushing

眉间皱痕 提交于 2019-12-12 11:17:54
问题 I have a bunch of unit test files, all of which consist of django.test.TestCase classes. Wrote myself a little shell script to uncomment/comment test file imports in my __init__.py file, so I can run tests from certain test files, based off the command line arguments I give it. I am also able to run all the tests of all the test files in one go (for regression testing purposes). I have this one test file that has some JSON fixtures and the first test checks that a certain model/table has 3

comparing querysets in django TestCase

无人久伴 提交于 2019-12-12 09:29:41
问题 I have a very simple view as follows def simple_view(request): documents = request.user.document_set.all() return render(request, 'simple.html', {'documents': documents}) To test the above view in my test case i have the following method which errors out. Class SomeTestCase(TestCase): # ... def test_simple_view(self): # ... some other checks docset = self.resonse.context['documents'] self.assertTrue(self.user.document_set.all() == docset) # This line raises an error # ... The error i get is

getting-java-io-ioexception-when-running-junit-test-case-in-eclipse (continued)

喜你入骨 提交于 2019-12-12 04:43:37
问题 I've just found a proxy somewhere and applied to my code, seem to be successful. But when it comes down to submit("btnG"), I got an syntax error SyntaxError: syntax error (httpunit; line 155) at org.mozilla.javascript.NativeGlobal.constructError(NativeGlobal.java:597) at org.mozilla.javascript.TokenStream.reportSyntaxError(TokenStream.java:1324)... 回答1: Submit from net.sourceforge.jwebunit.junit.WebTestCase is deprecated, so if this is what you are trying to use then you will have some issues

Django Test mocked ImageField prevent upload or clean after tests

旧巷老猫 提交于 2019-12-12 03:08:59
问题 I am working on a TestCase for my project, involving some Image and FileFields. Some objects are loaded with fixtures, some objects are created during the tests. I Mocked my image with a InMemoryUploadedFile. When creating a new test object, the mocked image is being uploaded to the MEDIA_ROOT directory, in the correct location defined in the upload_to method. These mocked images are actually being stored locally during the tests. There is quite some information about how to mock an image .

TFS Test Plans Merge from different Projects

淺唱寂寞╮ 提交于 2019-12-11 18:06:59
问题 I would like to merge an existing MTP (Master Test Plan) defined as a Test Suite with subfolders and TestCases, into another MTP (same structured), but located in a different project in TFS2017. The idea is to have both project sharing the same MTP, so any change can be visible in both projects. By now, I've just seen the existing possibilities about cloning/copying test cases between different test suites, but all of them should be part of the same project. I guess there must be an easy way

Rally toolKit for Java how do i create and then attach a TestCaseResult to a TestCase

孤街浪徒 提交于 2019-12-11 11:40:45
问题 general code where testCase is a JsonObject : JsonObject result = new JsonObject(); result.addProperty("Verdict", "True"); result.addProperty("TestCase", Ref.getRelativeRef(testCase.get("_ref").getAsString())); CreateRequest createRequest = new CreateRequest("TestCaseResult", result); CreateResponse createResponse = restApi.create(createRequest); I guess the two main questions I have are: Am I creating the testCaseResult correctly?(with the testCase property being a reference to a testCase)

Getting java.io.IOException when running JUnit test case in Eclipse

喜夏-厌秋 提交于 2019-12-11 10:48:01
问题 Here's my code public class JWebUnitTest extends WebTestCase { public JWebUnitTest(String name) { super(name); } public void setUp() { getTestContext().setBaseUrl("http://www.google.com"); } public void testSearch() { beginAt("/"); setFormElement("q", "httpunit"); submit("btnG"); clickLinkWithText("HttpUnit"); assertTitleEquals("HttpUnit"); assertLinkPresentWithText("User's Manual"); } } In the Failure Trace, I see the following error: java.lang.RuntimeException: java.io.IOException (moving

Test case for 100% branch coverage with no fault?

半世苍凉 提交于 2019-12-10 13:09:35
问题 The problem statement is A method that has a zero fault that you can write a test suite to that has 100% statement coverage but doesn't find the fault and another test suite that has 100% branch coverage that does reveal the fault? Here is the method I wrote for the same public faultyMethod1(int x, int y) { int X =x; int Y = y; if (Y !=0){ Z = X/Y; } else { System.out.println("Sorry. That's an DiviDeByZeroException"); } } faultyMethod1 (1,2); faultyMethod1 (2,0); The above code to achieve

run code when unit test assert fails [closed]

99封情书 提交于 2019-12-09 13:33:08
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . I'm using assertEquals() from unittest.TestCase . What I want to do now is to call a function and do something there when the assertion fails, I wonder if there's a way of doing this? 回答1: In general you shouldn't do it, but if you really want to, here is a simple example: import unittest def testFailed(): print

Test case data for convex-hull

时光总嘲笑我的痴心妄想 提交于 2019-12-09 12:58:03
问题 I need to make a 2D convex hull function for a class assignment and I want a more robust test cases than the assignment provides. Does anyone known of a largish test cases (25 < n < 100) with the solution? 回答1: The Qhull package, including qhull , qconvex , and rbox should do the trick (I've used them for this exact purpose myself). For example, the qconvex examples page gives the following (tweaked for a larger test case): rbox 100 D3 | qconvex s o TO result The above computes the 3-d convex