Questions tagged [expected-exception]
90 questions
2
votes
1 answer
Console displays exception message but is still wrong exception type -- Why?
I am attempting to create an abstract data type called bag, which essentially takes in integers with the method add(int x) and removes an arbitrary integer with the method remove().
Then, I tried to create a custom exception for the remove() method…

umop apisdn
- 653
- 9
- 20
2
votes
1 answer
Is possible to property to a message in ExpectedException?
I'm trying to validate the exception and message returned, but i have a file name in this message that is variable. Is possible to do that using unit test in just one method?
public static string FileName
{
get
{
…

Gabriel Miranda
- 57
- 5
2
votes
1 answer
PHPUnit: continue after die, expect "die" or somehow handle die()?
Possible Duplicate:
How do you use PHPUnit to test a function if that function is supposed to kill PHP?
I'm writing some unit tests. The system I'm currently testing is a web-app in an MVC framework.
If we want to render pages without the…

Alex C
- 16,624
- 18
- 66
- 98
2
votes
0 answers
Junit expect assertion called
This answer specifically answer's my question
In Junit is there a way to make sure the code makes it past a certain point?
ex:
@Test(expect = SpecialException.class)
public void testMyCode() {
…

dtracers
- 1,534
- 3
- 17
- 37
2
votes
0 answers
Assert exception with parameters using Junit
How can I check that an Exception with specific parameters is thrown, using ExpectedException. Suppose I have AcmeException which returns different error messages based on the parameters: AcmeException(One) returns One while…

tutak
- 1,120
- 1
- 15
- 28
2
votes
1 answer
C macro not working as expected
I am trying to adapt some code I have downloaded from here (supposedly correct) for making it work with my setup and CPU, but my compiler doesn't seem happy with it. I am using Keil v5 with an nrf51422 (Cortex M0 core), the code I have downloaded…

Vitomakes
- 315
- 4
- 12
2
votes
1 answer
Gradle error - expecting anything but ''\n''; got it anyway
I'm getting this error while running one Gradle task.
:46:52 * Where:
14:46:52 Initialization script '/production/builds/jenkins_slave01/gradle-1.6/init.d/extra1.common-thids.gradle' line: 119
14:46:52
14:46:52 * What went wrong:
14:46:52 Could not…

AKS
- 16,482
- 43
- 166
- 258
2
votes
2 answers
How can I expect an exception of a type that is not visible to the unit test assembly?
If I consume a WCF service, the following example client code is generated:
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization",…

qJake
- 16,821
- 17
- 83
- 135
2
votes
1 answer
How can I use JUnit's ExpectedException to check the state that's only on a child Exception?
I'm trying to refactor this old code that does not use ExpectedException so that it does use it:
try {
//...
fail();
} catch (UniformInterfaceException e) {
assertEquals(404, e.getResponse().getStatus());
…

Daniel Kaplan
- 62,768
- 50
- 234
- 356
2
votes
1 answer
How can a create a test case in ASP.NET C# for DatabaseConnection Error using ExpectedException?
I want to create a test case for Database Connection Error.
Any ideas how to do this?

Mark
- 21
- 1
1
vote
1 answer
Is there a way to provide failure message with ExpectedException attribute?
I want to provide a message when assertion has failed but I can't figure out a way to do it.
[Test]
public void CreateInstanceTest()
{
SomeClass someClass = new SomeClass();
Assert.IsNotNull(someClass, "Constructor could not return an…

Ufuk Hacıoğulları
- 37,978
- 12
- 114
- 156
1
vote
1 answer
Mbunit Factory attribute with ExpectedException
Is there a way to write that I'm expecting a certain exception for certain inputs when I use the Factory attribute?
I know how to do it using the Row attribute but I need it for dynamically generated test inputs.
See test example bellow for a…

Butcher
- 395
- 1
- 3
- 4
1
vote
1 answer
Python selenium send_keys brokes text
I use python + selenium to add some text into the text area (in DOM it is a DIV tag).
For example, I have the following text:
EVERY SINGLE picture or video you will publish with
after using send_keys() function the text inside textarea became…

Roman
- 1,883
- 2
- 14
- 26
1
vote
1 answer
XMLSyntaxError: Start tag expected, '<' not found, line 1, column 1
I am trying to build a script to query the UK National Grid API. Here is my code so far:
import requests
import pandas as pd
from lxml import etree
def getXML(toDate, fromDate, dayType):
url =…

DJW001
- 143
- 2
- 10
1
vote
2 answers
Lua - can't access key value. Always returns table
So I've run into a few identical problems with Eclipse and Lua and Love2D.
In these cases, I've created a table, say fonts. It's in main.lua. In fonts{}, I create key pairs like this:
fontsize = 24
gFonts{
['smallFont'] =…

John Lardinois
- 109
- 2
- 11