Unit Testing in PL/SQL

Hi,
I m writing some packages and in that some procedures are there. Now i want to test these procedures. I have downloaded utPLSQL from sourceforge.net
But I am unable to use it. Do we need to copy those utPLSQL files where the orcale is present ? If so and after that do we need to run any .sql scripts before going to do Unit Testing.
And please tell the procedure in brief in order to start Unit Testing.
Thanks in Advance.

I suggest you also check out Quest Code Tester for Oracle (disclosure: I design, build and use the tool - hey, I also wrote the original version of utPLSQL!), the first commercial automated testing tool for PL/SQL.
www.quest.com/code-tester-for-oracle
It generates virtually all of your test code, based on expected behavior you describe through a point and click interface. You can run tests through the UI or scheduled scripts.
Regards,
Steven Feuerstein
www.ToadWorld.com/SF

Similar Messages

  • Unit testing packages in sql developer

    It appears that the specify parameters window is blank for packaged functions which means the test call fails when run. Is this a grant or synonym issue ( or something similar ) or is there an issue with testing packages via the unit test interface of sql developer. Thanks in advance.

    Seems that you cannot right click on the packaged schema object from the schema connection i.e. you have to create the test from the unit test tab and then choose the object type i.e select packages and then the packaged function or procedure. This method results in the Specify Parameters window having the correct signature displayed. Procedures or methods can be created via the unit test tab or the active connection tab.

  • BUG: Unit Testing Process Validations SQL editor - extra spaces appended

    There is a bug in the SQL editor used by Unit Testing Process Validations.
    To re-create:
    Create a Validation with some multi-line SQL and save:
    select *
    from DUAL
    where 1=1
    Click on a different Validation, and then click back onto the Validation just created. SQL Developer will have appended a space to all the lines except the last one. Edit the Validation and save:
    select *
    from DUAL
    where 1=2
    When you navigate to a different validation and back, SQL Developer will have appended an extra space to each line. This can be repeated - each time an extra space will be added.

    There is a bug in the SQL editor used by Unit Testing Process Validations.
    To re-create:
    Create a Validation with some multi-line SQL and save:
    select *
    from DUAL
    where 1=1
    Click on a different Validation, and then click back onto the Validation just created. SQL Developer will have appended a space to all the lines except the last one. Edit the Validation and save:
    select *
    from DUAL
    where 1=2
    When you navigate to a different validation and back, SQL Developer will have appended an extra space to each line. This can be repeated - each time an extra space will be added.

  • Unit Test Variable Substitution in PL/SQL User Vailidation code not running

    Hi
    I am using new Unit Test Feature in SQL Developer 2.1.0.62.
    I have created a test implemented to test a function. The function has a VARCHAR2 parameter as input and returns a BINARY_INTEGER.
    I would like to perform 'Process Validation instead of specifying an explicit 'Result'. The check box 'Test Result' is unchecked.
    I have seen in the doc. that I can use substitution variables in my user defined PL/SQL code. I try
    IF {RETURNS$} < 0
    THEN ...
    but I always get the error
    ERROR
    <RETURN> : Expected: [Any value because apply check was cleared], Received: [-103]
    Validation User PL/Sql Code failed: Non supported SQL92 token at position: 181: RETURNS$
    Obviously, the program doesn't recognize {RETURN$}.
    Am I missing something?
    br
    Reiner

    Hi all,
    I have installed the latest version of SQL Developer (2.1.1) that fixed the problem - must have been a bug.
    The only problem was that I got an ORA-904 TEST_USER_NAME... error. I export my tests, dropped the repository, created a new one and reimported everything. Now it works as it should.
    br
    Reiner

  • Unit Test exports between different SQL Developer versions

    Hi,
    I am having problems with trying to export and import unit test suites between SQL Developer versions. I can't find any documentation in this area. We have a number of unit test suites exported as XML files from version 2.1.1.64, and below are combinations of things I have tried:
    - I have tried to import a unit test suite into version 3.0.0.4 that was exported from version 2.1.1.64 and get the error "Import failed. unexpected null value". I expect that this is probably an unsupported action due to repository changes between the two versions - should I be able to do this?
    - I have upgraded the repository with unit tests in it. The unit tests run perfectly well in the upgraded repository. However, if I try to export any suites or individual tests, I get an error "Export failed.". A XML file is created but with what looks like only the header part of it.
    - I have created a new unit test suite in version 3.0.0.4 and this exports successfully.
    - I have gone into each test of a suite in the upgraded repository and made a change so that I can perform a commit. When I do an export, this does then work successfully.
    Therefore it appears that something is not carried out by default when the repository is upgraded, but this fixes itself if the test is amended and committed in the upgraded repository. Although this may be a workaround, we have 100's of tests and is not something I really want to do. Has anyone else experienced this and got any recommendations for this?
    Thanks, Pierre.

    Hi,
    I am having problems with trying to export and import unit test suites between SQL Developer versions. I can't find any documentation in this area. We have a number of unit test suites exported as XML files from version 2.1.1.64, and below are combinations of things I have tried:
    - I have tried to import a unit test suite into version 3.0.0.4 that was exported from version 2.1.1.64 and get the error "Import failed. unexpected null value". I expect that this is probably an unsupported action due to repository changes between the two versions - should I be able to do this?
    - I have upgraded the repository with unit tests in it. The unit tests run perfectly well in the upgraded repository. However, if I try to export any suites or individual tests, I get an error "Export failed.". A XML file is created but with what looks like only the header part of it.
    - I have created a new unit test suite in version 3.0.0.4 and this exports successfully.
    - I have gone into each test of a suite in the upgraded repository and made a change so that I can perform a commit. When I do an export, this does then work successfully.
    Therefore it appears that something is not carried out by default when the repository is upgraded, but this fixes itself if the test is amended and committed in the upgraded repository. Although this may be a workaround, we have 100's of tests and is not something I really want to do. Has anyone else experienced this and got any recommendations for this?
    Thanks, Pierre.

  • SQL Developer Unit Test

    I'm trying out the Unit Test tool in SQL Developer version 3.2.09 and I keep getting the following error on the Teardown Process:
    Teardown Table or Row Restore (1/1) failed: ORA-06502: PL/SQL: numeric or value error: character string buffer too small
    ORA-06512: at line 22
    I have no idea what line 22 refers to? I cannot seem to find more detailed information in order to correct the problem.
    Any insight or help would be great!
    Thanks,
    Paul

    I'm having the same issue with SQL Developer 3.2.20.09 on Oracle 11.2.0.3.0. However, I think it's somewhat data dependent as I've had success and I've also encountered the ORA-06502 error.
    I ran a generic test on a very simple table and was successful using the teardown restore of the table. The procedure isn't important in this scenario, but is given as reference to creating the test. The simple, successful case is given first.
    Note that in both cases/tests, the original table of data already existed, so I question the error message pointing to data being inserted is longer than the field allows or that data types are somehow different...+unless+ SQL Developer is translating or getting it wrong. ALSO NOTE, running the SQL inserts as given works if run through the worksheet. It's only in the Teardown that I see the ORA-06502 error message.
    Data
    CREATE TABLE EMPLOYEES (EMPLOYEE_ID NUMBER, COMMISSION_PCT NUMBER, SALARY NUMBER);
    Insert into EMPLOYEES (EMPLOYEE_ID,COMMISSION_PCT,SALARY) values (1001,0.2,8400);
    Insert into EMPLOYEES (EMPLOYEE_ID,COMMISSION_PCT,SALARY) values (1002,0.25,6000);
    Insert into EMPLOYEES (EMPLOYEE_ID,COMMISSION_PCT,SALARY) values (1003,0.3,5000);
    CREATE OR REPLACE PROCEDURE AWARD_BONUS AS
    BEGIN
    null;
    END award_bonus;
    Startup: Table or Row Copy
    description = "TMP$AWARD_BONUS_TEST" := SELECT ROWID AS SRC$ROWID, s.* FROM "EMPLOYEES" s
    source = "EMPLOYEES"
    temp = "TMP$AWARD_BONUS_TEST"
    Teardown: Table or Row Restore
    description = "TMP$AWARD_BONUS_TEST" -> "EMPLOYEES"
    source = "EMPLOYEES"
    key = PRIMARY KEY
    temp = "TMP$AWARD_BONUS_TEST"
    The above worked without error.
    The following did not work.* (Again, the procedure isn't relevant.)
    Data
    CREATE TABLE "xxdss_fact_detail_history"
    "fact_trx_id" NUMBER(15, 0),"number_of_records" NUMBER,
    "product_code" VARCHAR2(250 byte),"item_code" VARCHAR2(250 byte),
    "item_description" VARCHAR2(250 byte),"trade" VARCHAR2(250 byte),
    "item_system" VARCHAR2(250 byte),"unit" VARCHAR2(250 byte),
    "fuel_source" VARCHAR2(250 byte),"component" VARCHAR2(250 byte),
    "assembly" VARCHAR2(250 byte),"part" VARCHAR2(250 byte),
    "symptoms" VARCHAR2(250 byte),"diagnosis_item" VARCHAR2(250 byte),"coa"
    VARCHAR2(250 byte),"cchs_parts" VARCHAR2(250 byte),
    "region" VARCHAR2(250 byte),"state" VARCHAR2(250 byte),
    "county" VARCHAR2(250 byte),"zip" VARCHAR2(250 byte),"vendor_id" NUMBER,
    "vendor_site_id" NUMBER,"vendor_name" VARCHAR2(250 byte),
    "vendor_site" VARCHAR2(250 byte),"c_service_call_cost" NUMBER,
    "c_labor_cost" NUMBER,"c_part_cost" NUMBER,"c_tax" NUMBER,
    "c_cchs_oh_cost" NUMBER,"c_cchs_total_low_cost" NUMBER,
    "c_cchs_total_high_cost" NUMBER,"c_cchs_avg_total_cost" NUMBER,
    "c_nc_c_labor_cost" NUMBER,"c_nc_c_part_cost" NUMBER,"c_nc_tax_cost" NUMBER
    ,"c_nc_total_low_cost" NUMBER,"c_nc_total_high_cost" NUMBER,
    "c_nc_avg_total_cost" NUMBER,"c_flat_low_cost" NUMBER,
    "c_flat_high_cost" NUMBER,"c_flat_avg_cost" NUMBER,
    "p_cycle_time_day_low" NUMBER,"p_cycle_time_day_high" NUMBER,
    "p_cycle_avg_time_day" NUMBER,"p_reasgn_low" NUMBER,"p_reasgn_high" NUMBER,
    "p_reasgn_avg" NUMBER,"p_recall_low" NUMBER,"p_recall_high" NUMBER,
    "p_recall_avg" NUMBER,"s_sp_nps_score_low" NUMBER,
    "s_sp_nps_score_high" NUMBER,"s_sp_avg_nps_score" NUMBER,
    "s_cchs_nps_score_low" NUMBER,"s_cchs_nps_score_high" NUMBER,
    "s_cchs_avg_nps_score" NUMBER,"cps_cost" NUMBER,"cps_perfrmce" NUMBER,
    "cps_sat" NUMBER,"coa_score" NUMBER,"comments" VARCHAR2(4000 byte),
    "complete_flag" VARCHAR2(1 byte),"last_update_date" DATE,
    "last_updated_by" NUMBER(15, 0),"creation_date" DATE,
    "created_by" NUMBER(15, 0),"last_update_login" NUMBER(15, 0),
    "vendor_number" VARCHAR2(200 byte)
    SET DEFINE OFF;
    Insert into XXDSS.XXDSS_FACT_DETAIL_HISTORY (FACT_TRX_ID,NUMBER_OF_RECORDS,PRODUCT_CODE,ITEM_CODE,ITEM_DESCRIPTION,TRADE,ITEM_SYSTEM,UNIT,FUEL_SOURCE,COMPONENT,ASSEMBLY,PART,SYMPTOMS,DIAGNOSIS_ITEM,COA,CCHS_PARTS,REGION,STATE,COUNTY,ZIP,VENDOR_ID,VENDOR_SITE_ID,VENDOR_NAME,VENDOR_SITE,C_SERVICE_CALL_COST,C_LABOR_COST,C_PART_COST,C_TAX,C_CCHS_OH_COST,C_CCHS_TOTAL_LOW_COST,C_CCHS_TOTAL_HIGH_COST,C_CCHS_AVG_TOTAL_COST,C_NC_C_LABOR_COST,C_NC_C_PART_COST,C_NC_TAX_COST,C_NC_TOTAL_LOW_COST,C_NC_TOTAL_HIGH_COST,C_NC_AVG_TOTAL_COST,C_FLAT_LOW_COST,C_FLAT_HIGH_COST,C_FLAT_AVG_COST,P_CYCLE_TIME_DAY_LOW,P_CYCLE_TIME_DAY_HIGH,P_CYCLE_AVG_TIME_DAY,P_REASGN_LOW,P_REASGN_HIGH,P_REASGN_AVG,P_RECALL_LOW,P_RECALL_HIGH,P_RECALL_AVG,S_SP_NPS_SCORE_LOW,S_SP_NPS_SCORE_HIGH,S_SP_AVG_NPS_SCORE,S_CCHS_NPS_SCORE_LOW,S_CCHS_NPS_SCORE_HIGH,S_CCHS_AVG_NPS_SCORE,CPS_COST,CPS_PERFRMCE,CPS_SAT,COA_SCORE,COMMENTS,COMPLETE_FLAG,LAST_UPDATE_DATE,LAST_UPDATED_BY,CREATION_DATE,CREATED_BY,LAST_UPDATE_LOGIN,VENDOR_NUMBER) values (324,2,'L&F-MPP03TR','STCOL-SPL','Straight Cool Split System','HVAC',null,'STCOL-SPL',null,null,null,null,null,null,'REAPIR','N',null,'VA','ASHBURN','20148',22024,118957,'Air Lingus Inc',null,50,55,44,12,180,40,78,76.5,60,50,20,100,180,130,50,110,80,2,8,3.9323148148178,40,60,43,9,10,8.2,100,201,150,20,40,35,50,30,20,100,null,null,to_date('01-JAN-13','DD-MON-RR'),1,to_date('01-JAN-13','DD-MON-RR'),1,null,'122023');
    Insert into XXDSS.XXDSS_FACT_DETAIL_HISTORY (FACT_TRX_ID,NUMBER_OF_RECORDS,PRODUCT_CODE,ITEM_CODE,ITEM_DESCRIPTION,TRADE,ITEM_SYSTEM,UNIT,FUEL_SOURCE,COMPONENT,ASSEMBLY,PART,SYMPTOMS,DIAGNOSIS_ITEM,COA,CCHS_PARTS,REGION,STATE,COUNTY,ZIP,VENDOR_ID,VENDOR_SITE_ID,VENDOR_NAME,VENDOR_SITE,C_SERVICE_CALL_COST,C_LABOR_COST,C_PART_COST,C_TAX,C_CCHS_OH_COST,C_CCHS_TOTAL_LOW_COST,C_CCHS_TOTAL_HIGH_COST,C_CCHS_AVG_TOTAL_COST,C_NC_C_LABOR_COST,C_NC_C_PART_COST,C_NC_TAX_COST,C_NC_TOTAL_LOW_COST,C_NC_TOTAL_HIGH_COST,C_NC_AVG_TOTAL_COST,C_FLAT_LOW_COST,C_FLAT_HIGH_COST,C_FLAT_AVG_COST,P_CYCLE_TIME_DAY_LOW,P_CYCLE_TIME_DAY_HIGH,P_CYCLE_AVG_TIME_DAY,P_REASGN_LOW,P_REASGN_HIGH,P_REASGN_AVG,P_RECALL_LOW,P_RECALL_HIGH,P_RECALL_AVG,S_SP_NPS_SCORE_LOW,S_SP_NPS_SCORE_HIGH,S_SP_AVG_NPS_SCORE,S_CCHS_NPS_SCORE_LOW,S_CCHS_NPS_SCORE_HIGH,S_CCHS_AVG_NPS_SCORE,CPS_COST,CPS_PERFRMCE,CPS_SAT,COA_SCORE,COMMENTS,COMPLETE_FLAG,LAST_UPDATE_DATE,LAST_UPDATED_BY,CREATION_DATE,CREATED_BY,LAST_UPDATE_LOGIN,VENDOR_NUMBER) values (465,4,'L&F-MPP03TR','STCOL-SPL','Straight Cool Split System','HVAC',null,'STCOL-SPL',null,null,null,null,null,null,'REPLACE','N',null,'VA','ASHBURN','20148',1768,1090523,'Airmax Heating And Air Conditioning Llc',null,65,50,80,15,110,50,60,70,70,40,20,100,180,130,50,110,80,3,5,0.878969907411374,10,70,20,1,2,2,130,150,140,20,40,60,40,30,30,100,null,null,to_date('01-JAN-13','DD-MON-RR'),1,to_date('01-JAN-13','DD-MON-RR'),1,null,'101767');
    CREATE OR REPLACE PROCEDURE dss AS
    BEGIN
    null;
    END dss;
    Startup: Table or Row Copy
    description = "TMP$DSS_TEST" := SELECT ROWID AS SRC$ROWID, s.* FROM "XXDSS_FACT_DETAIL_HISTORY" s
    source = "XXDSS_FACT_DETAIL_HISTORY"
    temp = "TMP$DSS_TEST"
    Teardown: Table or Row Restore
    description = "TMP$DSS_TEST" -> "XXDSS_FACT_DETAIL_HISTORY"
    source = "XXDSS_FACT_DETAIL_HISTORY"
    key = PRIMARY KEY
    temp = "TMP$DSS_TEST"

  • Unit Testing  - Results greater than 0

    I am unit testing a PL/SQL function. The function has no inputs and one output (Interval Day to Second) . The output is the time it takes to run a query therefore a valid value for the output would be greater than 0.
    When I setup the test the result only takes a Interval Day to Second value. I want to be able to say any result greater than 0 is a success.
    How can I do this?
    tom

    I am unit testing a PL/SQL function. The function has no inputs and one output (Interval Day to Second) . The output is the time it takes to run a query therefore a valid value for the output would be greater than 0.
    When I setup the test the result only takes a Interval Day to Second value. I want to be able to say any result greater than 0 is a success.
    How can I do this?
    tom

  • Create Unit Test wizard does not populate parameters

    If I right click a standalone function or procedure and select "Create Unit Test", the parameters window is populated and I am able to enter input and expected output values for the test.
    However, when I attempt the same with a function that is within a package, the parameters window is blank.
    I am using version 3.2.20.09

    Looks like someone has already reported this bug (and a workaround) in this thread:
    unit testing packages in sql developer
    Edited by: AJMiller on Dec 11, 2012 9:24 AM

  • SQL Developer 2.1: Problem exporting and importing unit tests

    Hi,
    I have created several unit tests on functions that are within packages. I wanted to export these from one unit test repository into another repository on a different database. The export and import work fine, but when running the tests on the imported version, there are lots of ORA-06550 errors. When debugging this, the function name is missing in the call, i.e. it is attempting <SCHEMA>.<PACKAGE> (parameters) instead of <SCHEMA>.<PACKAGE>.<FUNCTION> (parameters).
    Looking in the unit test repository itself, it appears that the OBJECT_CALL column in the UT_TEST table is null - if I populate this with the name of the function, then everything works fine. Therefore, this seems to be a bug with export and import, and it is not including this in the XML. The same problem happens whether I export a single unit test or a suite of tests. Can you please confirm whether this is a bug or whether I am doing something wrong?
    Thanks,
    Pierre.

    Hi Pierre,
    Thanks for pointing this out. Unfortunately, it is a bug on our side and you have found the (ugly) "work-around".
    Bug 9236694 - 2.1: OTN: UT_TEST.OBJECT_CALL COLUMN NOT EXPORTED/IMPORTED
    Brian Jeffries
    SQL Developer Team

  • SSDT: Creation of localDB instances from project file - Sql Server Unit testing purposes

    I have a SqlServer Database Project in my solution (VS2013 Professional) which has a corresponding test project with some stored procedure unit tests. Currently I am using a LocalDB and as far as I understand a local database instance is created in C:\Users\[User]\AppData\Local\Microsoft\Microsoft
    SQL Server Local DB\Instances\Projects and the specific .mdf file referenced in the SQL Server Object Explorer is in C:\Users\[User]\AppData\Local\Microsoft\VisualStudio\SSDT\[ProjectName]. The unit tests run fine on my local machine which I have developed
    the project on.
    My issue is we have a box which is configured to check out the project file from our version control, build the project using ms build commands and then run the unit tests using VSTest.Console. Usually with C# Test projects we reference the test project
    dll and the unit tests run fine. I have referenced the dll for the test project with the stored procedure unit tests in. 
    With the Stored Procedure unit tests however we get this exception: 
    Initialization method [project].[spTest].TestInitialize threw exception. System.Data.SqlClient.SqlException: System.Data.SqlClient.SqlException: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 50 - Local Database Runtime error occurred. The specified LocalDB instance does not exist.
    After some digging I have realised that the localdb instance seems to be created when the project itself is created in VS not when it is built. Specifically when the localdb is first used and if you look into the appData folder of the test machine there
    is no corresponding mdf file for the project.  
    The question is is there a way to set up a localDB instance on the new machine if all you have the project file? The only purpose of the project on the test machine is to run the unit tests, no other development purposes. VS2013 Professional is installed
    on the test machine but a solution only using config file changes or MSBuild/VSTest commands would be preferable.
    I realise you could change the connection string to an actual test database and run the unit tests of that but we quite like the localdb approach for the testing. I also realise that you could potentially transfer the mdf file (haven't tested this solution)
    as well, though I would prefer if there is a solution to my initial question. 
    http://technet.microsoft.com/en-us/library/hh234692.aspx
    http://msdn.microsoft.com/en-us/library/hh309441(v=vs.110).aspx
    I have been reading up on LocalDB and I assume a automatic LocalDB is created when you create a sql server database project (ie on localdb first use). I have tried adding the database creation to the test project config file but do not really know where
    to go from there. The second link does not really specify when the named localdb will be created if you add the config items and I am not even sure if that is an actual solution.  Here's my test project config file for reference
    <configSections>
    <section name="system.data.localdb" type="System.Data.LocalDBConfigurationSection,System.Data,Version=4.0.0.0,Culture=neutral,PublicKeyToken=[PublicKeyToken]"/>
    <section name="SqlUnitTesting_VS2013" type="Microsoft.Data.Tools.Schema.Sql.UnitTesting.Configuration.SqlUnitTestingSection, Microsoft.Data.Tools.Schema.Sql.UnitTesting, Version=12.0.0.0, Culture=neutral, PublicKeyToken=[PublicKeyToken]" />
    </configSections>
    <system.data.localdb>
    <localdbinstances>
    <add name="SimpleUnitTestingDB" version="11.0" />
    </localdbinstances>
    </system.data.localdb>
    <SqlUnitTesting_VS2013>
    <DatabaseDeployment DatabaseProjectFileName="..\..\..\SimpleUnitTestDB\SimpleUnitTestDB.sqlproj"
    Configuration="Release" />
    <DataGeneration ClearDatabase="true" />
    <ExecutionContext Provider="System.Data.SqlClient" ConnectionString="Data Source=(localdb)\Projects;Initial Catalog=SimpleUnitTestDB;Integrated Security=True;Pooling=False;Connect Timeout=30"
    CommandTimeout="30" />
    <PrivilegedContext Provider="System.Data.SqlClient" ConnectionString="Data Source=(localdb)\Projects;Initial Catalog=SimpleUnitTestDB;Integrated Security=True;Pooling=False;Connect Timeout=30"
    CommandTimeout="30" />
    </SqlUnitTesting_VS2013>
    Thanks in advance for any response. Sorry if there is any misunderstanding, while I have been using VS to develop from the start, this is the first time I have used a Sql Server Database Project. 
    Regards,
    Christopher. 

    Yes, you can create a LocalDB instance manually. You use the SqlLocalDb utility, see here:
    http://technet.microsoft.com/en-us/library/hh212961.aspx
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Unit testing PL/SQL used in APEX application

    question from my customer :
    I am developing an application in Oracle Application Express and am working on unit tests for the PL/SQL stored procedures and packages that are stored in the underlying database and that are used by the APEX application. These unit tests should run within the SQL Developer Unit Test framework.
    The problem is that some of the PL/SQL code stored in the database uses functions like NV('APPLICATION_ITEM') to access items in the apex application. These do not return any values when I try to execute the PL/SQL within the unit test framework, ie through the backend. While it is good that the NV function does not error, NULL do not really work well in my scenario either (for example when the result of this functions is inserted into a NOT NULL column of a table). I can think of a few workarounds, such as creating my own NV function inside the test schema to return desirable values, but nothing seems a really satisfactory solution. I just wonder if there is any best practice recommendation from Oracle for this scenario - how can I run code that uses APEX-specific functions through the back end. I could not find anything in the APEX documentation for this but I'd be interesting to know if there is any recommendation how to best deal with this case.
    I am using SQL Developer version 4.0.0.13.80

    User[[:digit:]*
    Your PL/SQL Package APIs are poorly designed.
    You need to take Tom Kyte's quote to heart:
    "Application come and application go, but data remains forever"
    In short, you need to separate your database processing code (the stuff you need to unit test) from front-end/middle tier code.
    (repetitiveness is for effect.. not rudeness.)
    As such, The PL/SQL code that you need to 'UNIT TEST' must work without needing to run in APEX.
    The PL/SQL code that you need to 'UNIT TEST' must work without needing to run in .NET.
    The PL/SQL code that you need to 'UNIT TEST' must work without needing to run in JSP.
    The PL/SQL code that you need to 'UNIT TEST' must work without needing to run in Jive.
    The PL/SQL code that you need to 'UNIT TEST' must work without needing to run in Ruby.
    The PL/SQL code that you need to 'UNIT TEST' must work without needing to run in Perl::CGI.
    The PL/SQL code that you need to 'UNIT TEST' must work without needing to run in P9.
    The PL/SQL code that you need to 'UNIT TEST' must work without needing to run in <place latest and greatest thing here>.
    Again, I don't mean to sound rude.  I'm just trying to reinforce the idea that you need to separate database code from middle-tier/front-end stuff.
    Basically, you will need to separate all of your packages into multiple parts.
    a _CORE package (that will be unit tested) that does all the hard work
    an _APEX package for APEX infrastructure (this works with NV()/V(), etc.)
    a _NET package for .NET infrastructure when you need it
    a _JSP package for the JSP infrastructure when you need it
    a _JIVE package for the JIVE infrastructure when you need it
    a _<place latest and greatest thing here> for the <place latest and greatest thing here> when you need it.
    MK

  • SQL Developer Unit Testing - Validation with PL/SQL

    Hi,
    I am trying to create Unit tests using SQL Developer UT framework.
    But when i am creating validation using User PL/SQL code option.
    Then how can i check value returned by l_count in code snippet below:
    -- Please raise an exception if the validation fails.
    -- For example:
    DECLARE
    l_count NUMBER;
    wrong_count EXCEPTION;
    BEGIN
    SELECT count(*) into l_count
    FROM test_recon
    WHERE
    match_num = 99836936
    AND Stg_status_flag <> 'E';
    IF l_count = 0
    THEN
    RAISE wrong_count;
    END IF;
    END;
    Also, can someone please refer me to few more demo examples (apart from oracle docs) to implement good test cases with SQL developer.
    I appreciate your help.
    Regards
    Dipali

    Probably not the answer you're looking for, but back when I was playing around with the Unit Test stuff, I didn't have sys privs, and the DBAs were a little busy at the time to set a up a repository for me. Rather than wait, I installed Oracle XE on my machine and created a small dev schema and deployed unit test to that. It's so much easier to perform quick proof of concepts when you have full control.

  • Using SQLCMD variables in SQL Server Unit Test Project

    Is it possible to use SQLCMD variables in my SQL Server Unit Test Project? In my test initialize script I'd like to set a database name variable, something like this:
    :SETVAR MyDatabase "mydatabase"
    SELECT * FROM [$(MyDatabase)].[mytable]
    but I get syntax errors when I run the test. Any suggestions how I can get this to work.
    Result Message: Initialization method
    myTest.TestInitialize threw exception. System.Data.SqlClient.SqlException: System.Data.SqlClient.SqlException:
    Incorrect syntax near ':'..

    Hi Kevin,
    What is the error?
    This should work only thing i could see is no scheme specified.
    SQL Server uses dbo as default schema.
    In your case:
    :SETVAR MyDatabase "mydatabase"
    SELECT * FROM [$(MyDatabase)].dbo.[mytable]
    Also check your instance collation if its Case sensitive then specify database and table name as exact case.
    Example:
    :SETVAR MyDatabase "[mydatabase]"
    :setvar schemavar "[dbo]"
    :setvar tablevar "[mytable]"
    SELECT * FROM $(MyDatabase).$(schemavar).$(tablevar)

  • SQL Developer 3.0 Unit Test

    Hi all,
    I'm hoping that one of you very knowledgeable individuals may be able to assist me!
    I'm an APEX developer, and I'm trying to make use of Hudson (www.hudson-ci.org) to automate my build process. I can successfully check files out of a source control repository and run them on my database, but I'm falling down when I try to use SQL Developer 3.0 from the command line to execute some unit tests.
    My test environment is a Windows XP SP3 machine running an 11g DB, APEX 4.1 and SQL Developer 3.0. In SQL Developer, I've set up a connection called APPHOME and currently, my unit test repository is on the same connection. If I open a command prompt and execute:
    C:\sqldeveloper\bin>ututil -run -suite -name TEST_PROCEDURE_SUITE -repo APPHOME -db APPHOME -log 1
    It works fine. The suite of tests execute OK, I get UT_SUCCESS back and when I look in SQL Developer, the result is there.
    However, if in a Hudson project I include an instruction that tries to fire exactly the same command, I get a response of: "Connection not found: APPHOME".
    Do I need to do anything special to ensure that ututil will be able to see the connection? The only thing that I can think of is that when I execute ututil from the command line, it does so as the logged in user (me, and I'm the one who has created the connections in SQL Developer) whereas when its fired by Hudson, it is executing as some other user that doesn't have my connections?
    Does anybody have any thoughts about this?
    Thanks in advance!
    Nick

    Hi Nick,
    I think your diagnosis is correct i.e. the connections are specific to your user. To resolve, you can try logging onto the Hudson server as the user that will run ututil, run up sqldeveloper client and import the connections into that user.
    I hope this helps.
    Philip Richens
    SQLDEV Development Team

  • SQL Developer 3.0 Unit Testing

    Hi folks,
    Firstly, let me say thanks for all the hard work that has gone into the improvements made in SQL Developer 3.0. I've been trailing EA3 for the past few days, and am so far very impressed.
    My development team are particularly interested in the improvements made to the Unit Test module. We have previously created a number of tests/test suites in 2.1, but when we select to connect to the old test case repository schema, 3.0 tells me that it can not find the repository. (Apologises, I do not have my development box in front of me, so I can't quote the exact message).
    Is there anything I can do to get it to recognise the old repository? I'd prefer not to have to recreate all of our existing tests...
    Thanks in advance,
    Nick

    Hi Mikka,
    Only simple PL/SQL Records are currently supported i.e. those that do not contain repeating or optional components and where all the components are themselves supported. This restriction is in place due to the fact that we use JDBC as the parameter passing mechanism which does not directly support the PL/SQL Record type.
    ANYTYPE and ANYDATA are not currently supported as they have a dynamic value type and therefore must be programmatically set. In the future, it may be possible to support these through the dynamic value and and validation features.
    This will remain so for the final version.
    Regards,
    Richard

Maybe you are looking for

  • How to get a value from Specific XML Node

    Hi all, I'm just trying to introduce to XMLType and see the potencialities of that. DB version: Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bi PL/SQL Release 10.2.0.5.0 - Production CORE     10.2.0.5.0     Production TNS for IBM/AIX

  • Trouble connecting Ipod Touch 2G to Belkin Tunecast auto

    Hi there! I just bought my Ipod Touch 2G on this Chritsmas and find it really cool, but... I have this one problem, when I try to connect it to my new Belkin Tunecast auto, it just doesn't stop sending the audio trough the internal speakers in order

  • Tns-12560 protocol adapter error linux

    I m running two independent oracle 11g on red hat 5 in vmware workstation 7 which is sitting on window xp where i m running 10g. I was facing a lot of networking when using tnsping. during my search i found that SUlinux and firewall was on which i tu

  • Some .htm file not displaying in Topic List, but displaying in RH11 folder

    Hi All, We are running a project using RH 11, team consist of 3 person (include me) But we have problem with many  .htm file from my 1st coworker, file not displaying in Topic List in my Robohelp and 2nd coworker. Although we already get the latest f

  • Reg: how to count no.of records in flat file

    Hi, Very god morning to all, i faced a one problem like this, i am new to jython code.my problem is i want count the no.of records flat file before loading to the table, is there any easiest way to count the number records in file rather than jython