testcase

run code when unit test assert fails [closed]

不打扰是莪最后的温柔 提交于 2019-12-03 17:24:03
Closed. This question is off-topic. It is not currently accepting answers. Learn more . 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? 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)

Automatically create test cases for web page?

对着背影说爱祢 提交于 2019-12-03 09:09:35
If someone has a webpage, the usual way of testing the web site for user interaction bugs is to create each test case by hand and use selenium. Is there a tool to create these testcases automatically? So if I have a webpage that gets altered, new test cases get created automatically? You can look at a paid product. That type of technology is not being developed as open source and will probably cost a bit. Some of the major test tools get closer to this, but full auto I have not heard of. If this was the case the role of QA Engineer and especially Automation Engineer would not be as important

Test cases for string inputs [closed]

前提是你 提交于 2019-12-03 06:07:29
What are some useful test case ideas (and test questions) related to string inputs? Usefulness need not mean applicable everywhere or all the time--just often enough to be worth considering when you address a new problem/system/domain. Individual answers may contain questions specific to certain domains (eg email address) but should probably point to a separate wiki-question. Please add your answer BOTH to the question and to the list of answers so that individual items may be voted upon. Some answers: See https://github.com/minimaxir/big-list-of-naughty-strings Blank/null string Whitespace

NUnit TestCase with Generics

折月煮酒 提交于 2019-12-03 04:43:11
问题 Is there any way to pass generic types using a TestCase to a test in NUnit? This is what I would like to do but the syntax is not correct... [Test] [TestCase<IMyInterface, MyConcreteClass>] public void MyMethod_GenericCall_MakesGenericCall<TInterface, TConcreteClass>() { // Arrange // Act var response = MyClassUnderTest.MyMethod<TInterface>(); // Assert Assert.IsInstanceOf<TConcreteClass>(response); } Or if not, what is the best way to achieve the same functionality (obviously I'll have

NUnit TestCase with Generics

余生长醉 提交于 2019-12-02 17:53:07
Is there any way to pass generic types using a TestCase to a test in NUnit? This is what I would like to do but the syntax is not correct... [Test] [TestCase<IMyInterface, MyConcreteClass>] public void MyMethod_GenericCall_MakesGenericCall<TInterface, TConcreteClass>() { // Arrange // Act var response = MyClassUnderTest.MyMethod<TInterface>(); // Assert Assert.IsInstanceOf<TConcreteClass>(response); } Or if not, what is the best way to achieve the same functionality (obviously I'll have multiple TestCases in the real code)? Update with another example... Here is another example with a single

How to write a junit testcase for a void method that creates a new object

大憨熊 提交于 2019-12-02 09:09:24
public class SupportController{ public void disableUserAccount(String username) throws Exception { UserAccount userAccount = new UserAccount(Constants.SYSTEM, Constants.CONTAINER, username); UserAccount.disableAccount(); } } How would i test that the useraccount created is disabled? I would suggest using Mock Objects . Besides that, you can check the JUnit FAQ , where you can find a section about testing methods that return void . Often if a method doesn't return a value, it will have some side effect. Actually, if it doesn't return a value AND doesn't have a side effect, it isn't doing

Rally add test case results in bulk using web services API

耗尽温柔 提交于 2019-12-02 07:21:45
问题 We are about to start the phase of updating test results in Rally via the api. I couldn't find an example to do this via the web services API (e.g. posting xml). Can anyone point me to this? Also I wondered what ability there is to do this in bulk, e.g. upload a set of test results in one go. Perhaps there are connectors for this that will upload various test result standards (e.g. JUnit report) into Rally? Thoughts and ideas welcomed. Thanks, Andy 回答1: If you're doing a simple POST against

Rally add test case results in bulk using web services API

北城余情 提交于 2019-12-02 07:21:09
We are about to start the phase of updating test results in Rally via the api. I couldn't find an example to do this via the web services API (e.g. posting xml). Can anyone point me to this? Also I wondered what ability there is to do this in bulk, e.g. upload a set of test results in one go. Perhaps there are connectors for this that will upload various test result standards (e.g. JUnit report) into Rally? Thoughts and ideas welcomed. Thanks, Andy If you're doing a simple POST against the Test Case Result Create REST endpoint: https://rally1.rallydev.com/slm/webservice/1.41/testcaseresult

JUnit testcase passes with eclipse but fails with maven build

自闭症网瘾萝莉.ら 提交于 2019-12-01 22:32:42
I wrote a JUnit test case for JPA using spring. The testcase passes in eclips. But if I execute the same testcase using maven (mvn test) it fails. My test case is : import javax.annotation.Resource; import junit.framework.TestCase; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.transaction.TransactionConfiguration; import org.springframework.transaction.annotation.Transactional; @RunWith(SpringJUnit4ClassRunner

Laravel TestCase not sending Authorization headers (JWT Token)

限于喜欢 提交于 2019-12-01 17:46:19
Summary We are writing unit tests to test the creation and invalidation of JWT tokens and receiving a "The token could not be parsed from the request" error back from a JWTException every time we try to JWTAuth::invalidate the token. Description Inside our controller, to create a user token, we are passing through the user email address and then returning the JWT token. Afterwards, we are destroying the token by invalidating it using invalidateToken method and passing through the token by sending an Authorization header. public function invalidateToken() { try { JWTAuth::invalidate(JWTAuth: