Author Topic: How to get all the different Test types.  (Read 6693 times)

Stenvang

  • EA User
  • **
  • Posts: 50
  • Karma: +0/-0
    • View Profile
How to get all the different Test types.
« on: October 29, 2014, 02:11:40 am »
I want to get all the different types a Test can be. The standard types which EA provides and the types I've added manually.

So the output would be something like this:
//Output
//Standard
//Regression
//Load
//CustomType1
//CustomType2

How do I do this? Is there any sort of collection I can loop through?

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: How to get all the different Test types.
« Reply #1 on: October 29, 2014, 04:14:47 am »
Check the contents of t_testtypes

q.

Stenvang

  • EA User
  • **
  • Posts: 50
  • Karma: +0/-0
    • View Profile
Re: How to get all the different Test types.
« Reply #2 on: October 31, 2014, 12:09:46 am »
And it is possible to add a customtype from code?
I've tried this:
Repository.SQLQuery("INSERT INTO t_testtypes VALUES (Default)");

But it returns a message saying invalid SELECT statement.
Is it only possible to select something?

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: How to get all the different Test types.
« Reply #3 on: October 31, 2014, 01:32:03 am »
You need to call Repository.Execute instead. Though it's an undocumented feature it works and is used by quite some users.

q.

Stenvang

  • EA User
  • **
  • Posts: 50
  • Karma: +0/-0
    • View Profile
Re: How to get all the different Test types.
« Reply #4 on: October 31, 2014, 01:52:28 am »
Thanks!
Now I just need to find the correct syntax for the SQL statement :)

Do you know if the feature is getting documented in the near future?

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: How to get all the different Test types.
« Reply #5 on: October 31, 2014, 02:25:15 am »
For sure it will never be documented. Though Sparx expose a bit of their internal tables they keep covered most of it (for good reasons). However, its use is common so it very likely will always be present.

Regarding SQL: there are some nice sites with SQL syntax charts. I once downloaded one and use it offline. Remember: SQL is not SQL! Each vendor has its own little spice.

q.
« Last Edit: October 31, 2014, 02:26:01 am by qwerty »

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8083
  • Karma: +118/-20
    • View Profile
Re: How to get all the different Test types.
« Reply #6 on: October 31, 2014, 08:48:59 am »
See Repository.GetReferenceList("Test")

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: How to get all the different Test types.
« Reply #7 on: October 31, 2014, 09:26:40 am »
Quote
See Repository.GetReferenceList("Test")
Ah, a new one :) For sure I have to harvest those new API methods to put it in my book(s).

q.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8083
  • Karma: +118/-20
    • View Profile
Re: How to get all the different Test types.
« Reply #8 on: October 31, 2014, 10:29:25 am »
Actually, I think it's been there since the API was first created.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: How to get all the different Test types.
« Reply #9 on: October 31, 2014, 10:59:58 am »
Surprise, surprise  :D 9.3 had it already (which is the oldest I keep for tests). So you're likely right.

Even more surprising: I already have it in my Scripting book  ::)

q.
« Last Edit: October 31, 2014, 11:02:51 am by qwerty »

Stenvang

  • EA User
  • **
  • Posts: 50
  • Karma: +0/-0
    • View Profile
Re: How to get all the different Test types.
« Reply #10 on: October 31, 2014, 06:44:20 pm »
Just to add the SQL syntax if others are looking for the same as me.

Repository.Execute("INSERT INTO t_testtypes (TestType, Description, NumericWeight, Notes) VALUES ('Default', 'Default value','1,000000','Some description')");

To find the SQL syntax first Select from the table so you can see the column names and then write your insert into statement.

Does the API has a equivalent method for this Repository.Execute that doesn't make the user write an actual SQL statement?
« Last Edit: October 31, 2014, 06:47:54 pm by Stenvang »

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: How to get all the different Test types.
« Reply #11 on: October 31, 2014, 10:00:09 pm »
For "common" element you use AddNew for a collection. But for tables like the above that doesn't work. You either have to stick to Repository.CustomCommand or .Execute (both undocumented features). I rather like to go with Execute since I don't need the deviation X via XML.

q.

Stenvang

  • EA User
  • **
  • Posts: 50
  • Karma: +0/-0
    • View Profile
Re: How to get all the different Test types.
« Reply #12 on: November 04, 2014, 01:24:32 am »
Another question on the same topic that occurred to me was that if I loop through all the tests in an element there is no way I can differentiate the unit tests from integration tests or system tests and vice versa.

I couldn't find an appropriate t_something either.

However the user interface can differentiate between the types. So I guess there is a way to do it through the API too, I just can't find it.

Any help here?
Should I start a new question for this?

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: How to get all the different Test types.
« Reply #13 on: November 04, 2014, 03:28:30 am »
Have a look into t_objecttests.TestClass. It' a numeric value related to the tabs you see in the test window.

q.