Why and how to write reproducible test cases

We all have been in situations where the application we were developing or maintaining did not do what we expect it to do. This happens all the time. No big deal you think, but after hours of trying to figure out the problem, you still are stuck.

In my experience it helped to stand back a bit and trying to look at the problem from a different angle. There are different ways to do this. One is to try to talk to someone else and to try to explain the problem. I  sometimes see the problem during explaining the problem, sometimes when I try to explain what I have tried to resolve the problem. The interesting part is the the person you talk to does not even have to be a programmer.

In my other post I tried to give some rules on how to ask questions on OTN, so I assume you have done anything in this direction and still don’t have a working solution. Now, there are problems which are not solved after this. This is the point where you should think about writing a reproducible test case. The remaining post is about how to write such a test case in a way you get the most out of it and make it easy for others to help you solve the problem.

A test case should fulfill some requirements:

  1. it must reproduce the problem
  2. it must be as easy as possible in doing this
  3. it should be easy to use by other users which don’t work in your environment
  4. it should use a data model which is known by other users (without the need to study table definitions, triggers, …)
  5. if a known data model can’t be used the model must be described in great detail
  6. if possible it should not be necessary to change  or insert data
  7. if data has to be changed or inserted you should include scripts or steps to get the original data back
  8. it should not take longer than 15-20 minute to setup everything

You might think that it will cost a lot of your time to create such a test case. You are right, it will cost you some time, but this time is well spend:

  1. chance is that you’ll find the problem and it’s solution while creating the test case. Then you are done and can be proud of yourself.
  2. creating the test case forces you to get a clear picture of the problem. This helps to describe the problem to others
  3. providing a test case to the community increases your chance that somebody find the problem and helps you fixing it drastically
  4. If nobody can help you and you ask support.oracle.com for help, they will ask you for a reproducible test case too. Normally the work  faster if you can provide one and have a good description of the problem.

After you now know the reasons and requirements for a test case let’s talk about how to create one. I always use the HE DB schema provided with every Oracle DB (or you can get it from Oracle Sample Model and Scripts). Almost every developer has access to an running HR DB instance. Depending on the problem and the relation to the original data I choose only the minimum number of tables needed to create the test case.

Lets say the problem in your app happens in a data entry form which consists of a master-detail-detail data. Then I look at the HR model and use Regions, Countries, Locations as data model for the test case. Depending on the data you can choose different tables, e.g. Departments, Employees, Jobs.

Once the data model (or the tables) are known, I create a simple ‘ADF Fusion Web Application’ which will create a workspace with two projects. The model project I create by using the ‘Business Components from Table…’ option you get by right clicking on the model project and then selection ‘New’. As the whole process is to long to describe I made screenshots from every dialog . The sample application is created with JDev version so you might not exactly see the same images.

Creating the workspace:

Creating the model project:

Checking the model project:

After this the basic workspace for the test case is finished and can be used to add the problem specific parts. Here you start with the business logic and add whatever you need to show hte problem in the UI.

If your problem is related to cascading selectOneChoice in a form, it’s a good idea to add the configuration to the model project and test this using the application module tester. Once the business logic is running you continue with setting up the UI. Here you don’t have to design a pretty looking UI. Make it as simple as you can. Concentrate on showing the problem.

Here are some specific things you should take into account:

  1. if your problem needs a fancy design, e.g. you have a layout problem or a skin problem, then you sure add all needed resources to reproduce the problem.
  2. if your problem needs specific data in the DB, you should create DDL scripts to create the tables and to insert data into the tables. Avoid to add table space names and other storage information in hte scripts as other users likely don’t have those table spaces. A description of the data model is mandatory!
  3. if your case needs third party libraries you must provide the exact version of the libraries and hte location where we can download them! Smaller libraries you should add to the test case zip file.
  4. Write a detailed description on how to start the application (which page to run) and what to do to get to the problem.
  5. Format your code! I hate reading unformatted code. It costs time to interpret things which I would like to spend on solving the problem, not by trying to figure out which part of code I’m looking at.
  6. Comment your code! The better the code is commented the easier we can understand what you have tried to do. In a perfect world I wold like to understand the code by just reading the comments of the methods without having to go into the details of the implementation. Once the problem area is clear I start looking into the implementation. One thing I do is to read the comment of a method and checking it against it’s implementation.

Finally you zip everything together and make the zip file available to the public. Make sure that you delete unnecessary files and folders from the workspace (like .data and .classes). These folders are huge and are recreated automatically when you compile the application. Pay special attention to library files (jars) which are sometimes huge. As you are given us the version and location where to download them (and instructions where to put them!) they can be omitted. You can use Google Drive or Dropbox which are well known to other developers. I you use an unknown file host service you risk that nobody downloads the test case.

One final word of advice

We are all trying to help but have our normal work to do too. Creating a test case, even after you are asked to provide one, doesn’t mean that you get help from other users. There is no service level agreement (SLA) attached!

If you need urgent support ask Oracle Support or help. The test case will help you there too as support don’T need weeks to understand and reproduce the problem.





JDeveloper is out


Today October, 19th 2016 JDeveloper was released. From the first look at it it’s only a maintenance release.  There is currently no ‘What’s new’ document, only a release notes are available.

The release notes show only some bug fixes and some deprecation. Noteworthy are some changes in the REST runtime. One of them is that ADF REST HTTP PUT is deprecated functionality. From the doc

ADF REST HTTP PUT is deprecated functionality

Oracle has deprecated the functionality for executing HTTP PUT methods on ADF REST resource requests. In the current release, the describe for ADF REST resources continues to display PUT actions when the backing view object has the Update operation enabled (the operation enables both PUT and PATCH methods); however, ADF REST service clients should avoid making PUT requests (replace all items of the view row) as this functionality will be desupported in a future release

Another change in the REST department is that adf date and datetime attributes are no longer described as string but as date and datetime. Interesting if you work with ADFbc and Oracle JET.

There are some other small bug fixes and deprecation’s of oracle.domain data types and the dvt:stockGraph. You should use dvt:stockChart instead.

Let’s wait if Oracle releases an ‘What’s new’ document in hte near (?) future which will spear us some time searching for new stuff 🙂

How to Ask Questions in OTN Spaces

You have a problem which you can’t figure out yourself and  want to ask some other users for help. We all have been in this situation!

Even the veteran users (like myself) had run into such problems. We all are glad that the OTN spaces exists where we can ask other users for their input and help.

Sure it’s easiest for you to just open a question in OTN or support.oracle.com (MOSC) and just ask

“I have a problem fitting my QTY_X  into the pivot”

Then you’ll get plenty of fire from other users who don’t really know what you are talking about. It will take some questions and your answers and after one or two days, the thread is already 8-10 posts long, the others have a basic understanding of the problem. This is what I call waste of time.

It would have been easier, if you had given the full use case at the beginning. This would have cost you a couple of minutes work (max. 30 min) but would have saved 24 hours in question and answers. So, here are some basic rules of how to ask questions:

  1. search the forum if your question has been asked before (and
    answered). The forums search isn’t that bad 🙂
  2. search again using Google. Don’t give up after reading the first hit
  3. give information about your environment like versions of software you use. This is essential as versions change and other users might run into a similiar problem never knowing if the thread they read was about their version
  4. give a full understandable use case of the problem. The process of formulating a good forum question, will force you to think more clearly about the question yourself.  Sometimes in the middle of writing the question the answer comes to you because you’ve restated the problem in terms an outsider can understand
  5. tell us what you have already tried to solve the problem. Help the others to get the big picture and show that you not just dump your work on the forum users
  6. give information about the technologies you use in your application. If you e.g. POI to generate native EXCEL files and this is related to your problem, we should know. If you use PL/SQL to make changes in the DB we should nḱnow too
  7. providing code snippets and any other information which you think helps us to understand the problem or what you have tried to solve it
  8. Screenshots help understand visual problems. It’s hard to describe problems with are only visual like “my fields are not aligned”. Make screenshots and add them to your post.
  9. Provide stacktraces as text if you are ask to provide one. This way we can look at each part.
  10. Format code you provide. This make code readable, regardless if it’s Java, PL/SQL or the source of a .jsff page.

The list above is not complete but a starting point. Giving this information will help you getting an answer to your question.

Please remember that all users have normal jobs to do to get the bills paid. Phrases as ‘ASAP’, ‘urgent’ have no meaning at all . There is no ‘Service Level Agreement’ attached to the OTN Spaces. If you need urgent help you should use support.oracle.com, the paid support Oracle offers.

OTN Appreciation Day: Developer Cloud Service

Tim Hall had the great idea to introduce the ‘OTN Appreciation Day’ where bloggers should write a short blog about their favourite Oracle feature. As the OTN is a great network which I use every day, I like to add a blog about my current best like feature, the ‘Oracle Developer Cloud Service’.

So, why is the Developer Cloud Service my favoured feature?

I’m a consultant, coach and architect helping customers to bring their Oracle related projects to a good start, sometimes back on track, help migrate projects to current versions an coach developers. There are many questions where customers ask to see how something is going to work or how to set something up. Before the DCS, setting up an environment which is similar to the customers was a time consuming task.

I had to install software like JDeveloper, WebLogic Server, SOA Suite and Database most often before getting to the real task.  Coaching developers in new techniques like using git or automate software deployment (continuous integration) needs software too.

The DCS offers an ready to use environment to develop software and deploy it to WebLogic Server already setup with the needed packages like ADF and/or SOA Suite. You can plugin your own DB or use the one running in the cloud.

Agile development can be done with the DCS too. You can use an integrated bug tracker, use agile boards and create tasks you assign to developers of your team. Code reviews can be done and the Hudson server is used to build a new artifact including the last reviewed changes. Once they passed there automated tests, the new version can be automatically deployed to the server. The new version of the software is ready to be accessed from everybody. You get a full integrated DevOps platform!

This DCS makes my live as a consultant and coach a lot easier. Modern techniques can be shown and teached to customers. I also use the DCS for trainings the German ADF Community holds on multiple occasions. The DCS has evolved since end of 2015, more features have been added and more are in the pipeline to make it more productive in hte future.

To find out more about the Developer Cloud Service visit my other blog posts about the DCS or Oracle Developer Cloud Service.

If you want to try the DCS for yourself, you can get a free 30 day trial.