Regression Testing - Try Catch In Assert Statement

Jan 20, 2009

I am doing regression testing using NUnit, WatiN and VB.net. What I am doing is opening an IE page, selecting some data, making a registration and then on view registration page testing the registration by assertion. Any good way to use try and catch on every assert. i am using it because if some assert fails it will stop executing the rest of the statement and quits without running rest of the tests. Now I have put try and catch on every assert and writing the fail message in log file.

For instance If I am checking for some airline reservation booking. After creating a booking, On view Booking Summary Page I am testing weather it is displaying cancel booking button or not. For this I am using the following code:
Try Assert.IsTrue(_internetExplorer.Button(Find.ById(New Regex("CBooking"))).Exists)
Catch ex As Exception d_logger.LogResultTextFile("Cancel Button does not Exist", True, False) End Try
I am checking this by running this in a loop for no of bookings created. I want to keep running the test even if in one booking it wont finds the button but keep checking for other bookings.

View 1 Replies


ADVERTISEMENT

Is There A Graphic Regression Testing Tool That Anyone Knows Of

Mar 2, 2011

A long time ago. before .Net net existed, I used an automated and a graphical tool. It seens to me that it was made by Microsoft. Is there a graphic regression testing tool that anyone knows of?

View 1 Replies

Unit Testing - Use Assert.AreEqual To Evaluate If String Is Greater Than A Certain Length

Feb 1, 2011

I'm wondering how to evaluate an expression using the assert object. The idea is to check if a string is longer then what is minimally acceptable. For example, Assert.AreEqual(stringName.length, >5). I know this method doesn't work but the concept is what I'm trying to get across. Is there a way to test this?

View 1 Replies

Button_click Event Will Not Stop Execute After Error Catch Using Try - Catch Statement

Apr 1, 2011

i have problem when i click a ADD button, there is one null value in the textbox .. so the try catch statemnt is to catch that null value error but after that the catch is success but the button click never stop excute the statemnt till the end of the button event.

View 6 Replies

Exceptions - Can The "Throw" Statement Exist In A Block With No Try/catch Statement

Oct 5, 2009

how to use them then before, but am still a little confused with a few aspects. Here goes:

1.) Lets say you have a method that checks for a certain condition(s) and if it fails Throws an exception. Does it have to be in a try/catch block? Meaning can the "Throw" statement exist in a block with no try/catch statement?

2.) Now lets say we have a method that has a try catch block and in it there is a throw statement. When the throw statement is executed does it first try to find an appropriate catch block in the same method or does it immediately go back to the calling method without looking at the catch statements in the current method where the exception was thrown?

3.) I created a custom exception class that inherits from ApplicationException. Next I created a method which has a catch block that catches this type of exception and does some action. Is the System(i.e CLR) smart enough to throw an exception of this type, or does it only throw exceptions from SystemException?

4.) I know that some people are more liberal in their use of exceptions and others use it more sparingly when truly strange stuff happen like the DB going down. I am writing code where I am getting some info back from the database, converting it and then storing it. Sometimes there might be data that comes back from the database and other times the field is empty and the Null value comes back. Therefore in the instances where Null comes back from the database I should not convert the value to anything, since I will get an error. What should I do in this situation? Should I let the CLR throw the exception when it goes to convert the Null value or should I check for the Null value and if it exists not convert?

5.) In general when I throw exceptions, is it sensible to only throw exceptions of the type Application Exception or are there instances where the programmer throws exceptions of the type SystemException?

View 2 Replies

If Statement - Testing Multiple Values For Equality?

Mar 26, 2009

How do you test multiple values for equality in one line?
Basically I want to do
if (val1 == val2 == val3 == ... valN)
but in VB.Net.

View 3 Replies

How To Keep Thread When Using A Try...catch Statement

May 28, 2012

My.Computer.Network.DownloadFile(URL, Path, ... etc.)
Catch

[code].....

View 2 Replies

What Is The Point Of This Catch Statement

Sep 22, 2009

I seen this in legacy code. What, if any, is the purpose of a single Throw within a Catch?

[Code]...

Is the outcome the same as if the original error was not caught? Would you use a Throw statement w/o parameters to re-throw the original error, typically after performing some action first?

View 7 Replies

VS 2008 How To Use Try Catch Finally Statement

Jun 15, 2009

i want to know how to use try catch finally statement.i want to catch this error Violation of PRIMARY KEY constraint 'XPKemployee'. Cannot insert duplicate key in object 'dbo.employee'.

View 4 Replies

VS 2008 How To Use Try..Catch...Finally Statement

Mar 4, 2011

i have this problem about the try,catch,finally statement... i don't know how to use it..i have my converter program here and this should be type by a letter 'cause if you do it will go lag or hang...i try VERIFY button to make sure if it's a letter or number but my teacher said it's not counted...

Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If ComboBox1.Text = "Pounds To Kilo" Then

[code]....

View 14 Replies

Determine Error Type In Try Catch Statement

Sep 24, 2009

I'm interested in having a generic 'Try Catch' clause, with some case statements or if/than statements within the Catch part so that I can handle different error types differently. some way to get ex.Errorcode or ex.ErrorType that differentiates the different errors to a unique value.

How can this be done?

Try

'some code taht will throw an error'

Catch ex AS Exception
If ex.ErrorCode = 20 then
' Do something'

[Code].....

View 6 Replies

Asp.net - .NET Button Control, OnClick Event: (Try, Catch Statement)?

Oct 31, 2011

I have a button on a web page that I just need a little help with some extra code. I think I need a TRY, CATCH statement?, this is what I have so far: I have a simple web page that has a button which at the moment when pressed enables the user to add data to a DB table via a stored procedure.Once this button is pressed a pop up message box is displayed to let the user know the data has been passed. The user then needs to press the 'OK' button within this message box which then directs them to the home page of the site. This works fine.

The code for this is here:

Protected Sub btnAddRawData_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAddRawData.Click
'database conn, this is linked to the web config file .AppSettings
Using dbconnection As New SqlConnection(ConfigurationManager.AppSettings("dbconnection"))

[code]....

As I don't want the user to enter duplicate records in the database (This could be done by the user navigating back to the page where the btnAddRawData_Click is located and pressing it again.), I have created a UNIQUE INDEX named 'DupRecords' to stop the user from commiting this data more than once that day.When I run the web page now I get the following message in my browser:

Cannot insert duplicate key row in object 'dbo.GasRawData' with unique index 'DupRecords'.The statement has been terminated.The solution I think, is to add a TRY, CATCH statement into the btnAddRawData_Click code.

View 2 Replies

Set VS2008 To Break On An Error Inside A Try-catch Statement?

Feb 19, 2009

One of the things I loved about VB6 is that you had the ability to tell the development environment to break on all errors regardless of what error handling you had set up. Is it possible to do the same thing in VS2008 so that the debugger will stop on any error even if it happens inside a try-catch statement?

View 4 Replies

Try / Catch Exception Handling Breaking INSERT Statement

Sep 12, 2010

When trying to use Try/Catch in my code the INSERT statement does not work, but when I comment out the Try/Catch it works fine with no error. The section of my code is below:

[Code]...

View 2 Replies

Is Try / Catch / Finally Required With Using Statement In Order To Handle Exceptions

Jan 31, 2012

I wonder how to use statement handles exceptions?Do I need to wrap the using statements with a Try/Cath/Finally clause in order to be sure that the SqlConnection object is closed and disposed even if the containing code throws an exception? [code]

View 3 Replies

Sql - Unit Testing The Data Access Layer - Testing Update Methods?

May 15, 2009

I'm looking into adding some unit tests for some classes in my data access layer and I'm looking at an update routine that has no return value.It simply updates a row based on the id you provide at whichever column name you provide.Inside of this method, we collect the parameters and pass them to a helper routine which calls the stored procedure to update the table.Is there a recommended approach for how to do unit testing in such a scenario?

View 4 Replies

Difference Between NUnit Testing And Unit Testing In VSTS?

Aug 25, 2009

I use VS team system 2008. At the moment i need to test some business classes, i have found two kinds testing NUnit and the unit testing provided by the VS team system. what are there differences?

View 1 Replies

.net - Unit Testing C# InternalsVisibleTo() Attribute For NET 2.0 While Testing?

May 13, 2010

I'm building an Active Directory wrapper in VBNET 2.0 (can't use later .NET) in which I have the following:

IUtilisateur
IGroupe
IUniteOrganisation

These interfaces are implemented in internal classes (Friend in VBNET), so that I want to implement a façade in order to instiate each of the interfaces with their internal classes. This will allow the architecture a better flexibility, etc.Now, I want to test these classes (Utilisateur, Groupe, UniteOrganisation) in a different project within the same solution. However, these classes are internal. I would like to be able to instantiate them without going through my façade, but only for these tests, nothing more.

[Code]...

View 1 Replies

C# - Cannot Assert Against Object?

Jun 25, 2012

This is probably a very simple Object Oriented Programming question. What I am trying to do is take 2 empty objects, use a query to pull data from a database, populate the empty objects with the data returned from the query, and then assert against them. See the code below:

[Code]...

I wrote a very similar test method in VB following the same patterns and the VB code executed just fine.However whilst transitioning from VB to C#, I run into issues such as these. The compiler says "Use of unassigned variable" at the assert. However, I thought I was assigning to a value within the code block above. What am I doing wrong?

View 2 Replies

VS 2008 Try / Catch Statement - Error "Failure Sending Mail"

Feb 25, 2010

I'm e-mailing a message from my application to myself, I don't quite understand how to do this, but I did think I had finally gotten it right -

[Code]...

I've got that code in a try/catch statement and it shows me via a MsgBox the error "Failure sending mail".

View 5 Replies

Assert.Fail Within A Try Block?

Jun 23, 2011

My understanding of assert.fail was that if the line is executed, the test will fail.owever, I have found an instance where the assert.fail is executed, but the test passes.If the Assert.Fail statement is within a try block, the test will ALWAYS pass, even if the code execution executes the assert.fail. For example, the following test will always pass, even if the sub fails to throw an exception.

View 2 Replies

DirectoryEntry Memory Leak - Gets A Out Of Memory Error In The Last Catch Statement?

Jan 11, 2012

The follow code can be called about 6K times on the server it is run on then gets a out of memory error in the last catch statement. I don't see what is wrong with the code, it works well up until the out of memory..

Public Function AddUserToGroup(ByVal sSamAccountName As String, ByVal sGroupName As String) As Boolean
Try
Dim returnStatus As Boolean = True[code]......

View 3 Replies

How To Implement Linear Regression On Data

Apr 15, 2011

I'm looking for a reference showing how to implement linear regression on data in VB2005

View 1 Replies

.NET Unit Tests - Assert.IsTrue Message?

Feb 18, 2011

I'd like to add a message to be displayed in Visual Studio 2010 test results.I can post a message out if the test fails, but not true. Is there anyway to do this? For example:

dim quoteNumber as string = Sales.CreateQuote(foo)
assert.IsTrue(quoteNumber <> "")

'I would like to make this something like this:

assert.isTrue(quoteNumber <> "", falsepart, "Quote number " & quoteNumber & " created")

View 3 Replies

C# - Linear Regression/trend Line With Ms Charting

Jan 4, 2011

I have data that are numbers both on x and y and have charted them using mschart 4.0

I need to add a trend line/linear regression to a bunch of points I have. The data on x and y are both numbers (no dates anywhere), for instance (33.4,45.1) would be a point.

In the samples I downloaded from the first link I found a linear regression sample in the code files forecasting.aspx(.cs), and I found this ms documentation

I have added a linear regression line to the chart with the following line (once all other data it setup etc)

Chart1.DataManipulator.FinancialFormula(FinancialFormula.Forecasting, parameters, "Input:Y", "Forecasting:Y,Range:Y,Range:Y2");

The problem with both of these is that they assume dates are used. I went ahead and implemented it anyway, but my regression line starts at around the x value of 20, and will go to an x value of the max x value of one of the points (almost 70) if I give the parameter Period a value of 700. But since it doesn't start at x value 0 I don't trust it is correct.

View 1 Replies

VS 2005 : Generating A Folder Tree Using Regression?

Apr 1, 2010

This problem has been doing my head in all day and wouldn't mind a bit of advice. Basically I have a table in my db called tblTree which looks a bit like this :

TreeId, ParentId
1 0
2 0
3 2

Each row represent a folder.The TreeId is a unique Primary Key.The ParentId refers to the folder this belongs in so in the above example TreeId 3 is a folder created in the the folder represented by TreeId 2.The 0 in ParentId represents the root.How in Gods name am i supposed to create a folder structure using this table?

View 5 Replies

IDE :: Horizontal Slider Bars - Fit A Regression To A Subset Of Data

Jan 18, 2010

I have a set of x, eg 288, data values. The user wants to fit a regression to a subset of this data, eg (2 - 200), then she wants to analyse within a subset of this fitted range, eg at 20 and 100. So, on my form are four Hor. Slider Bars, to set the lower and upper bounds to the fitting and the analysis. The two that set the lower bounds work fine. The two that set the upper bounds are getting corrupted somehow outside of my code and I do not know how to solve this problem. What happens is that when I click on the right hand arrow on the slider bar, the program runs through my function with the correct values whilst the arrow is down, goes out of my code and then immediately comes back into my code, but with the wrong value set into the Hor. Slider Bar fields that I am working with, eg the .Value field. The new value is always 9 below the maximum that it can be, but I can see no connection to this number.

View 1 Replies

.net - Come The Debug.Assert Line Causes A Compile Error In Release Mode?

Sep 20, 2011

I'm surprised to get a compile error in release mode with the following code.I have a DEBUG only function declared

#If DEBUG Then
Private Function DEBUG_Check() As Boolean
'Do some checks[code]....

I get a compilation error "DEBUG_Check is not declared"I thought calls to Debug.Assert were completely removed from Release compile?

View 1 Replies

Error - Catch Cannot Catch Type 'Microsoft.Office.Interop.Outlook.Exception'

Mar 25, 2011

I have a program in VB.Net that receives mails from Outlook, extracts attachments and inserts the attachments into a table through a query. I would like to put the query/queries in a Try/Catch block, but cannot do so as Outlook exceptions cannot be caught, and it gives me an error, and unless I put a very specific exception, I cannot catch it. Is there a workaround?

Edit:

Try
Catch ex As Exception
End Try

Exception is underlined and when I hover on it, it says: "Catch cannot catch type 'Microsoft.Office.Interop.Outlook.Exception' because it is not in 'System.Exception' or a class that inherits from 'System.Exception'". This is affecting all my other code which I'd like to put into a Try/Catch block.

View 2 Replies

Restructure Try / Catch To Eliminate Error On Myreader.close Command In Catch Part?

Jun 19, 2012

The following code causes a "Warning" that Variable is used before value assigned.How do I restructure this Try/catch to eliminate error on the myreader.close command in the Catch part? Code appears to work fine but I dont like Warnings. [code]

View 8 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved