ABL Unit Test 11.6 - Catching customized errors using assert

Posted by atuldalvi123 on 02-Jun-2016 04:47

How can we catch the customized errors returned from the called class methods in the ABLUnit Test?

Customized errors like undo, throw new apperr " Error msg  " or langerr "  Error msg ".

All Replies

Posted by atuldalvi123 on 02-Jun-2016 10:36

any update guyz ?

Posted by Laura Stern on 02-Jun-2016 12:20

Not sure what the question really is.  I don't know much about ABLUnit, but the ABLUnit methods would have to throw any error that occurred.  Then you would catch it as you normally would any other error with a CATCH block.

So are you asking how to catch an error?  Are you asking how the ABLUnit methods can throw an error back to the caller?

Posted by Phani Sajja on 03-Jun-2016 00:41

If there is an error while executing the test the test is considered as a failure case. You may not catch the error raised.

But you can specify the exception by passing a expected parameter to the Test case as shown below.

@Test(expected="OpenEdge.Core.AssertionFailedError"). 
    METHOD PUBLIC VOID TestPass(): 
        Assert:IsTrue(FALSE).
    END METHOD.

In the above case the test is considered to be passed.

Let us know if you are looking for something else.

--
Regards,
Phani S.

Posted by atuldalvi123 on 03-Jun-2016 01:33

if we pass this

@Test(expected="OpenEdge.Core.AssertionFailedError")

what it will do ?

Posted by Phani Sajja on 03-Jun-2016 01:48

The test case is considered pass if the error specified in expected attribute is raised.

That is a sample example. When you are testing application logic (a method for example), that might throw exceptions for certain input.

If you want to test your method is throwing an exception for certain input then you can specify that as part of expected attribute as showing in above snippet.

Posted by atuldalvi123 on 03-Jun-2016 02:42

OK Gr8.

One of the method is throwing customized error like below . How do i catch this error in my test ? or have to use simple catch statement ?

DO:    

                 UNDO, THROW NEW appError ("Error msg ").  

 END.

Posted by atuldalvi123 on 06-Jun-2016 01:58

any update on this guys ?

Posted by Mike Fechner on 06-Jun-2016 02:04

Beg my pardon. But this is a community forum - not a place with a SLA.

On your last question. You are not very clear on why you want to catch that error. But most likely you have answered your own question. Or it was already replied by Phani Sajja: CATCH or annotate.

Posted by atuldalvi123 on 13-Jun-2016 05:22

How can we change the  Results.xml path for the test results ?

Currently it is generating under the tests folder as a default directory.

Posted by Phani Sajja on 13-Jun-2016 07:11

By default, it will be created in working directory.

If you want to change, you change the working directory from 'Run Configurations' -> 'Working directory' in the ABLUnit main page.

It always overwrite this file if you run a different test entity in the next run.

You can use the Export feature from ABLUnit results view rather than relying on this results.xml file.

--

Regards,

Phani S.

Posted by DivyaTheja on 13-Jun-2016 07:15

If you are using PDS OE to run ABLUnit tests, results will be generated under working directory mentioned in PDS OE's ABLUnit run configuration. Changing working directory to other might help.

If you are running from command-line, you can use outputdir parameter to generated results in custom location.

Posted by atuldalvi123 on 14-Jun-2016 04:14

Thanks.

Now I am designing build.xml and adding DB names like

eg.

<dbinfo name="C:\OpenEdge\WRK114\s2000.db" host="localhost" port="4545" />

I am putting DB name, server name and port number  but while running the build.xml using Ant Build i am getting error in console " DB xxx is not a valid DB name", not sure y. DB is on separate server.

All the parameters are correct. Using editor if I put the same parameters in CONNECT statement, it is working for me.

But through build.xml I am getting that error.

Posted by Phani Sajja on 14-Jun-2016 06:44

If the db specified in the given location with name attribute is not available it will raise exception.

Make sure that the db 's2000.db' present in the specified directory 'C:\OpenEdge\WRK114', which you have given.

Posted by atuldalvi123 on 14-Jun-2016 07:47

My DB server is on another machine so i am giving only db name like "Test" not the whole path and passing other parameters like

<dbinfo name="Test.db" host="host007" port="4545" />

still not working .

Posted by Phani Sajja on 14-Jun-2016 08:49

You need to give the absolute path not simply 'Test.db'

Posted by atuldalvi123 on 14-Jun-2016 09:12

what do u mean by the absolute path  ?

Posted by Phani Sajja on 15-Jun-2016 01:40

The path is the full path where you created db. Eg, 'C:\SomeDir\Test.db'. You need to given the existing db in name field.

For example, if you created your db in C:\SomeDir with the name Test, your absolute path becomes 'C:\SomeDir\Test.db'.

At present, Ant expects that db to be presented locally.

Posted by atuldalvi123 on 15-Jun-2016 01:55

So ABLUnit test framework will not work if we have DB on another server or machine

As I have mentioned the absolute path of the DB of our server and still I am getting the same error message.

Posted by Mike Fechner on 15-Jun-2016 01:57

You don't use an absolute path to connect to a DB on another server. You use the short DB name, the host name and the port number or service name.

Posted by atuldalvi123 on 15-Jun-2016 02:02

Yes,I tried that also still I am getting the same error massage "Invalid DB name". The same parameters if I use in the CONNECT statement that works for me.

Posted by Mike Fechner on 15-Jun-2016 02:08

what is the exact error message? How does your connect statement look and how your startup parameters?

Posted by atuldalvi123 on 15-Jun-2016 02:23

I have attached below screenshot

In Connect statement I am using the same params like

CONNECT -db stddb -H Hostname -S PortNo

Posted by Mike Fechner on 15-Jun-2016 02:26

I don't see the error message yet. But I'd remove the ".db" part form the DB name. It is not part of the short DB name.

Posted by atuldalvi123 on 15-Jun-2016 02:28

Error message is there in the console, check bottom side of the screenshot. I checked with removing .db, still getting the same error.

Posted by Mike Fechner on 15-Jun-2016 02:34

The error message seems to show a folder name. So I would question that the ant script you are showing on the screen is the same ant script that raised that error message.

Posted by atuldalvi123 on 15-Jun-2016 02:41

Yes. one thing I observed here is that even after mentioning the remote host name and port it is searching DB in the working directory and raising this error message. In the console error is coming  like

"{working directory path} \ stddb is not a valid DB name"

Posted by Mike Fechner on 15-Jun-2016 02:46

In which case you should report a bug with tech support.

Posted by atuldalvi123 on 15-Jun-2016 02:49

is this really a issue / bug or m doing something wrong ?

Has anyone faced the same issue before ?

Posted by Mike Fechner on 15-Jun-2016 02:52

According to the docs you are doing everything right. Smells like a bug to me. Opening a tech-support case won't hurt.

Posted by atuldalvi123 on 15-Jun-2016 02:56

Is there any alternative for this so that I can finish my framework design ?

Posted by Mike Fechner on 15-Jun-2016 02:59

Software products don't improve when users don't report bugs.

But an alternative was already given by Phani Sajja in this discussion. Use an absolute path and use a local DB.

Posted by atuldalvi123 on 15-Jun-2016 03:15

don't know how do I report the bugs for progress tech supports, guide me on this so that I can report it.

Posted by Mike Fechner on 15-Jun-2016 03:17
Posted by atuldalvi123 on 15-Jun-2016 06:44

I have mapped my DB server drive on the machine where we have this test framework and supplied the required parameters. Now its working for me. But now I am connecting to couple of Dbs and one of the DB required user id and password.

How can we pass username and password information in <dbinfo...> tag ?

Posted by Riverside Software on 15-Jun-2016 13:57

Please note that if you're already using PCT (I think it was the case from previous messages), there's also an ABLUnit task ( github.com/.../ABLUnit ) in which you can reuse existing DBConnection.

Posted by atuldalvi123 on 16-Jun-2016 02:08

No, I am running build.xml from the 11.6 studio only as a ANT task and so facing this issue. one of the DB is asking for the user id and password but in xml we can not provide this as <dbinfo..> tag is not supporting these attributes.  Is there any alternative for this ?

Posted by Phani Sajja on 16-Jun-2016 02:24

Currently, username and password fields are also missing in the dbinfo tag.

Please report a bug for the same, or update in the previous one where it is missing remote db connection.

You may request a hotfix if you need immediate attention.

--

Regards,

Phani S.

Posted by Mike Fechner on 16-Jun-2016 02:28

Just to set your expectations... As you don't seem like someone who likes to wait. Progress is really fast with hot fixes when there is high urgency. But expect to wait for "a couple of weeks" at least. And you must make clear why there is urgency with your call.

Posted by atuldalvi123 on 16-Jun-2016 02:45

Hi Mike,

There is no as such urgency but whatever mentioned in the document for this build.xml, I am following those steps and facing these couple of issues and so posting on this forum. If i get something alternative that will be great for me to accomplish my task within the timeline.

Posted by Riverside Software on 16-Jun-2016 07:41

If you're looking for the alternative (or the standard way to build OE applications :-) ), you can use the ABLUnit task of PCT where username and passwords are already available.

Posted by atuldalvi123 on 16-Jun-2016 07:44

Do we need to install this PCT tool separately ?

Posted by Riverside Software on 16-Jun-2016 08:38

It's not bundled with Developer Studio, but it's just a JAR file to be copied in the right location

Posted by Mike Fechner on 16-Jun-2016 08:43
Posted by atuldalvi123 on 17-Jun-2016 01:50

How do I install this jar, configure and run build.xml from 11.6 studio ?

Not much information available on the above link

Posted by Riverside Software on 17-Jun-2016 02:54

Copy it in %DLC%\oeide\eclipse\plugins\org.apache.ant_1.8.4.v201303080030\lib

Ant version number can vary between versions.

Posted by atuldalvi123 on 17-Jun-2016 03:11

from where i can get this .jar file ?

Posted by Riverside Software on 20-Jun-2016 02:00

From the "Releases" tab ?

Posted by atuldalvi123 on 21-Jun-2016 06:43

I have downloaded PCT jar and kept in the %DLC%\oeide\eclipse\plugins\org.apache.ant_1.8.4.v201303080030\lib.

I gone through the example of AblUnit for PCT but that is for the set of unit test files. I want to run only one suit program for my test. Is that possible in PCT XML ?

Normally we use <test> tag to run the individual test. Is that supported by PCT xml ?

Also can we run this xml from OE11.6 studio as a ANT task ?

Posted by atuldalvi123 on 22-Jun-2016 05:01

I am running one sample PCT task for my testing from proenv and from Command line as mentioned on the URL site but its always giving me error on prompt like " The syntax of the command is incorrect ".

I defined these vars correctly ANT_HOME & JAVA_HOME and copied jar files in the  %DLC%\oeide\eclipse\plugins\org.apache.ant_1.8.4.v201303080030\lib aswel.

From my MyProject folder I am simply running "ant build" command but m getting this error

This thread is closed