Menu
  • HOME
  • TAGS

Should I write different test case for different branch of same service?

java,spring,testcase,test-coverage

is this test case covering all the branches ? No it does not. Obvious it does cover nothing, because it does not invoke the method under test at all! BTW: I do not know your repository, but it is likely that userRepository.save(user) always return the given user, so maybe...

How to resolve OptimisticLockingFailureException?

java,mongodb,spring-data,testcase

Optimistic locking exception means the object being persisted have already changed it's state in the database (some other transaction saved the object). So, this is a domain specific problem. You have to decide what should be done. Basically two options: Present the error to the user. Read the object from...

Is it OK to assert in unittest tearDown method?

python,testcase,unit-testing

Asserting something in your tearDown means that you need to be careful that all the cleaning is done before the actual asserting otherwise the cleaning code may not be called if the assert statement fails and raises. If the assert is just one line it may be OK to have...

call different methods in unittest according to input arguments

python,unit-testing,testcase

Yes you can! Straight from the unittest documentation on organizing your test code Assume you have a TestCase that looks like this guy: import unittest class WidgetTestCase(unittest.TestCase): def setUp(self): self.widget = Widget('The widget') def tearDown(self): self.widget.dispose() self.widget = None def test_default_size(self): self.assertEqual(self.widget.size(), (50,50), 'incorrect default size') def test_resize(self): self.widget.resize(100,150) self.assertEqual(self.widget.size(),...

run code when unit test assert fails [closed]

python,unit-testing,assert,testcase

In general you shouldn't do it, but if you really want to, here is a simple example: import unittest def testFailed(): print("test failed") class T(unittest.TestCase): def test_x(self): try: self.assertTrue(False) except AssertionError: testFailed() raise if __name__ == "__main__": suite = unittest.defaultTestLoader.loadTestsFromTestCase(T) unittest.TextTestRunner().run(suite) Another, more generic possibility is to write your own...

write unit test case in python for below algorithm

python,unit-testing,testcase

Test cases prove the correctness of your functions. How do you test correctness? By "proving" it. You therefore write test cases against your functions with predefined output so you can verify that it returns the expected result. Example : Using python's unittest module, you can write a test for a...

Junit - Mocking static method

junit,mockito,powermock,testcase,powermockito

You don't have defined your matchers correctly. Could you change it by: PowerMockito.when(RequestXmlBuilder.serviceMarshall(any(Request.class), any(Jaxb2Marshaller.class))).thenReturn("XmlTest"); Import for Mockito any matcher, as follows: import static org.mockito.Matchers.any; Cheers...

NUnit produces empty empty parameter test when using TestCaseSource and objects

c#,visual-studio-2013,nunit,testcase

You have a [TestCase] attribute on yours that isn't on the sample. The sample attributes: [Test, TestCaseSource("DivideCases")] Yours: [TestCase] [TestCaseSource("DivideCases")] ...

Robot Framework Test Flow

robotframework,testcase

This is not a good / recommended / possible way to go. Robot framework doesn't support it, and for a good reason. It is not sustainable to create such dependencies in the long term (or even short term). Tests shouldn't depend on other tests. Mainly not on other tests from...

Nunit runsTestCase with a TestCaseSource with the first iteration having no parameters? Why?

c#,unit-testing,nunit,testcase,testcasesource

TestCase and TestCaseSource do two different things. You just need to remove the TestCase attribute. [TestCaseSource("_nunitIsWeird")] public void TheCountsAreCorrect(List<string> entries, int expectedCount) { Assert.AreEqual(expectedCount,Calculations.countThese(entries)); } The TestCase attribute is for supplying inline data, so NUnit is attempting to supply no parameters to the test, which is failing. Then it's processing...

Getting the StackTrace for a TestCaseResult that Failed in TFS via API

c#,tfs,stack-trace,testcase

I think Visual Studio gets this info from the TRX file which it stores as an attachment to the test run. I got the attachment as follows: TfsTeamProjectCollection tfsCollection = new TfsTeamProjectCollection(new Uri("http://tfsserver:8080/tfs/CTS")); ITestManagementService tfsStore = tfsCollection.GetService<ITestManagementService>(); ITestManagementTeamProject tcmProject = tfsStore.GetTeamProject("MyProject"); // Get Test Run Data by Build ITestRun thisTestRun...

Junit : Cannot test header information in the response

java,junit,mockito,junit4,testcase

rsp.addHeader is also a mocked method and values you set there are not returned via rsp.getHeader. But you can verify if methods on your mock object are invoked using verify method. If you really want to have addHeader to work together with getHeader, you should consider using a spy object...

Add a test case to TestLink

testing,testcase,testlink,test-plan,test-project

You have to create the test cases definitions/descriptions in "Test Specification" for your "test project". Then in the "add/remove test" page, you will see the list of your test and you will be able to add them to your current campaign.

how to test split char test to search?

c#,string,linq,split,testcase

There were a few issues with the code. The first conditional "!String.IsNullOrEmpty (qurey)" would force any non-null or empty qurey value to stop processing at this time. Solution: Increased the scope of the conditional, so if the case is true, the application would end. The conditional statement for "else if...

Listing test results in VS2010 that DONT include a keyword

c#,visual-studio-2010,visual-studio,unit-testing,testcase

You can sort of cheat to pass this tests, if you want to, by marking that this test expects an exception to be thrown and thereby passes the test. [TestMethod] [ExpectedException(typeof(NotImplementedException))] public void NotYetImplementedMethod(Object args) { .... } Alternatively you can create categories for your tests. This way you can...

Are these requirements correct (variable relations)

variables,specifications,testcase,requirements

After having seen the original text, it is clear that the equation L - 2 W >= 10 is indeed the author's intent. This constraint makes sense. Anyway, there are two "bugs" left: the textual specification is wrong (should read "The length must be greater than twice the width by...

JIRA as a Test Case Management Tool

jira,testcase

JIRA is a ticketing system. As it's marketing buzzword bingo says: "Issue tracking and code integration to plan, collaborate, and ship great products." It does more if you find or create the necessary plugins. It does issue tracking by itself, and code integration with other Atlassian platforms. It does not...

NoMethodError on method added to Date class

ruby-on-rails,ruby,unit-testing,testcase

private doesn't work for class methods, and use self. class Date def self.new_from_hash(hash) self.new self.flatten_date_array hash end def self.flatten_date_array(hash) %w(1 2 3).map { |e| hash["date(#{e}i)"].to_i } end end ...

Common @before and @after for test classes in junit

java,junit4,testcase

The @Before and @After are applicable to inheritance: public abstract class AbstractTestCase { @Before public void setUp() { // do common stuff } } If you want to do specific stuff in each test case you can override it: public class ConcreteTestCase extends AbstractTestCase { @Before @Override public void setUp()...