Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Jubula » Adding checks to Teststyle
Adding checks to Teststyle [message #1263391] Tue, 04 March 2014 12:45 Go to next message
Daniel Hör is currently offline Daniel Hör
Messages: 7
Registered: February 2014
Location: Augsburg, Germany
Junior Member
Hi,

i'm writing a plugin for Jubula and i'm wondering if there is a way to add my own checks to Teststyle? I found the appropriate library (org/eclipse/jubula/client/teststyle), but it seems that most of the classes in this library are not accessable. There are only a few classes in the build path which are allowed by the access rules, but even if i change the access rules, i get ClassNotFoundExceptions...

Hope anyone can help me
Daniel
Re: Adding checks to Teststyle [message #1263516 is a reply to message #1263391] Tue, 04 March 2014 14:56 Go to previous messageGo to next message
Achim Loerke is currently offline Achim Loerke
Messages: 349
Registered: July 2009
Location: Braunschweig, Germany
Senior Member

Hi,

the org.eclipse.jubula.client.teststyle bundle contains just the infrastructure necessary to run the checks. For an example on how to implement checks have a look at the org.eclipse.jubula.client.teststyle.impl.standard bundle.

The classes exported from org.eclipse.jubula.client.teststyle are the base clases from which you might sub-class your checks. Please don't change any access rules because this limitations are there for a reason (i.e. to hide non-API classes).

- Achim

Re: Adding checks to Teststyle [message #1264836 is a reply to message #1263391] Wed, 05 March 2014 14:40 Go to previous messageGo to next message
Daniel Hör is currently offline Daniel Hör
Messages: 7
Registered: February 2014
Location: Augsburg, Germany
Junior Member
Thanks Achim, i can now add my check to the list in the Properties->Teststyle page. My next question is, how can i make this check run? I looked for some methods in the teststyle bundle but it seems to be more complicated..

Thanks a lot
Daniel
Re: Adding checks to Teststyle [message #1265637 is a reply to message #1264836] Thu, 06 March 2014 10:45 Go to previous messageGo to next message
Achim Loerke is currently offline Achim Loerke
Messages: 349
Registered: July 2009
Location: Braunschweig, Germany
Senior Member

Hi Daniel,

tried to contact you by phone but failed Sad

You don't need to run a check. This is done by the framework once you have added the check and marked it as "runnable" in the properties page. If you are in the IDE you can check this by setting a breakpoint in your check.

HTH

Achim
Re: Adding checks to Teststyle [message #1265823 is a reply to message #1263391] Thu, 06 March 2014 16:03 Go to previous messageGo to next message
Daniel Hör is currently offline Daniel Hör
Messages: 7
Registered: February 2014
Location: Augsburg, Germany
Junior Member
Hi Achim,

The framework doesn't run my check. But apart from that, i have some other problems creating the check:

1. How can i create a new Category? I didn't find the right method, so for testing i used an existing Category

Category tcCat = CheckCont.getCategories().iterator().next();


2. Am i right in assuming that the BaseContext of a check represents the class of the objects that should be checked?
So, since the BaseContext class is not accessable, the only way i found to set the context was to create an ICheckConfPO object:

IProjectPO project = GeneralStorage.getInstance().getProject();
ICheckConfContPO chkConfCont = project.getProjectProperties().getCheckConfCont();
ICheckConfPO chkConf = chkConfCont.createCheckConf();

Map<String, Boolean> contextMap = new HashMap<String, Boolean>();
contextMap.put("TestSuiteContext", true);

chkConf.setContexts(contextMap);
chkConf.setActive(true);


Actually i want Test Cases to be checked, but it seems that "TestSuiteContext" is the only key that is accepted. I tried it with ExecTestCaseContext and SpecTestCaseContext but i got a NullPointerException.

3. I'm not sure if i forgot something to implement the check:

TestCaseNamesCorrect tcCheck = new TestCaseNamesCorrect();
tcCheck.setName("TestCases must have specified names");
tcCheck.setFulltextDescription("TestCase names must match the pattern 'Txxxxxx'");
tcCheck.setId("jubulatestplugin.TestCaseNamesCorrect");
tcCheck.setConf(chkConf);
		
tcCat.addCheck(tcCheck);


public class TestCaseNamesCorrect extends BaseCheck {
    @Override
    public String getDescription() {
        return "TestCases must have specified names";
    }

    @Override
    public boolean hasError(Object obj) {
 		
   	if (obj instanceof ITestCasePO)
   	{
   		ITestCasePO tc = (ITestCasePO) obj;
		if (!Pattern.matches("T\\d{6}", tc.getName()))
			return true;
   	}
   		
   	return false;
    }
}


Thanks for your help, i'm sorry you could'nt contact me, maybe next time Smile

Daniel
Re: Adding checks to Teststyle [message #1266523 is a reply to message #1263391] Fri, 07 March 2014 15:19 Go to previous messageGo to next message
Markus Tiede is currently offline Markus Tiede
Messages: 6
Registered: July 2009
Location: Braunschweig, Germany
Junior Member
Hi Daniel,

to answer your questions:
1. Test style categories are defined by simply declaring a parent for a check in the plugin.xml - see [1] for further information.
2. Contexts are referenced as children of the check itself - see [2] for the already mentioned TestSuiteContext usage. Beside that there are also other contexts defined - a list of all realized contexts can be found here [3]. However at the moment you can not add contexts on your own by using an extension point. The context you are looking for can e.g. be found here [4].
3. To implement a check on your own you do not need to do more than providing the class which realizes the check (e.g. inherits from BaseCheck) - see [5] for an example: you only need to implement hasError(...) and getDescription(...). You also do not need to explicitly instantiate your class - this is automatically done reflectively by the RCP extension mechanism and the hasError() method gets invoked whenever the ITE triggers its "Completeness Check".

For additional information about RCP extension mechanisms and concepts I'd recommend to perform these tutorials [6] and [7].

Best regards,
MarkusT

[1] http://git.eclipse.org/c/jubula/org.eclipse.jubula.core.git/tree/org.eclipse.jubula.client.teststyle.impl.standard/plugin.xml#n13

[2] http://git.eclipse.org/c/jubula/org.eclipse.jubula.core.git/tree/org.eclipse.jubula.client.teststyle.impl.standard/plugin.xml#n23

[3] http://git.eclipse.org/c/jubula/org.eclipse.jubula.core.git/tree/org.eclipse.jubula.client.teststyle/schema/define.exsd#n194

[4] http://git.eclipse.org/c/jubula/org.eclipse.jubula.core.git/tree/org.eclipse.jubula.client.teststyle/schema/define.exsd#n263

[5] http://git.eclipse.org/c/jubula/org.eclipse.jubula.core.git/tree/org.eclipse.jubula.client.teststyle.impl.standard/src/org/eclipse/jubula/client/teststyle/impl/standard/checks/TestSuiteHasAUT.java#n23

[6] http://www.vogella.com/tutorials/EclipsePlugIn/article.html

[7] http://www.vogella.com/tutorials/EclipseExtensionPoint/article.html
Re: Adding checks to Teststyle [message #1269142 is a reply to message #1263391] Tue, 11 March 2014 12:53 Go to previous messageGo to next message
Daniel Hör is currently offline Daniel Hör
Messages: 7
Registered: February 2014
Location: Augsburg, Germany
Junior Member
Thanks a lot Markus, it works fine now. Nevertheless there are still two problems:

1. When i open a project, i want the plugin to check all objects. This happens only after i go to the property page and click OK. I could handle this problem by immitate this action in a ProjectLoadedListener, but this Listener is being called to early so the command works only if i let the Thread sleep a second. I think there must be a smarter method to implement this?!

DataEventDispatcher.getInstance().addProjectLoadedListener(new IProjectLoadedListener() {
	@Override		
	public void handleProjectLoaded() {
		try {
			Thread.sleep(1000);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		DataEventDispatcher.getInstance().fireProjectStateChanged(DataEventDispatcher.ProjectState.prop_modified);
	}
}, false);


2. I can't activate or deactivate the checks, or change the severity in the property page, because it gets reseted after clicking OK. This does'nt concern only my new checks but also the standard checks..

Thanks for help
Daniel
Re: Adding checks to Teststyle [message #1289715 is a reply to message #1263391] Wed, 09 April 2014 15:21 Go to previous messageGo to next message
Daniel Hör is currently offline Daniel Hör
Messages: 7
Registered: February 2014
Location: Augsburg, Germany
Junior Member
How can i access the Test Results? I want to check the last execution time of the test steps..

Daniel
Re: Adding checks to Teststyle [message #1291794 is a reply to message #1289715] Fri, 11 April 2014 08:14 Go to previous message
Achim Loerke is currently offline Achim Loerke
Messages: 349
Registered: July 2009
Location: Braunschweig, Germany
Senior Member

Test results are stored separately in the database. There are no direct dependencies modeled for those. To get test results for a specific run you have to load the result and maintain their life cycle yourself. The code for displaying the test results overview and the subsequent actions when opening an editor to display them will give you a good overview of this tasks.

There is, however, a catch. Test style actions are run at the discretion of the Teststyle framework. There is no life cycle support there. It would be difficult to ensure that the results are loaded at the appropriate time and it would be next to impossible to get rid of them (from memory) once they are no longer needed.

- Achim
Previous Topic:Does each external command happen in its own terminal?
Next Topic:central data set value ignored
Goto Forum:
  


Current Time: Sat Oct 25 19:08:11 GMT 2014

Powered by FUDForum. Page generated in 0.02842 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software