Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: Stenvang 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?
-
Check the contents of t_testtypes
q.
-
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?
-
You need to call Repository.Execute instead. Though it's an undocumented feature it works and is used by quite some users.
q.
-
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?
-
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.
-
See Repository.GetReferenceList("Test")
-
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.
-
Actually, I think it's been there since the API was first created.
-
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.
-
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?
-
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.
-
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?
-
Have a look into t_objecttests.TestClass. It' a numeric value related to the tabs you see in the test window.
q.