Thanks, that’s helpful.  I didn’t think to just use an import in the qml test 
file itself.  I’ll test today, but it doesn’t seem like that would work with 
nested objects.  If it does then great, but rather non-intuitive magic.

Also, currently I’m just stubbing out qml objects to represent c++ objects that 
would be available to the QML object being tested in the production 
application.  This is appropriate for unit testing, but if I could include the 
c++ classes in my test runner then I could do integration tests too which would 
be lovely.  Any chance you have an example of that?

Thanks,
j

On Jan 6, 2014, at 4:40 AM, Chao Caroline <[email protected]> wrote:

> Hi,
> 
> The TestCase doc should refer to QtQuickTest and not QtTest indeed, please 
> log a documentation bug for it.
> 
> Also I have attached a small example to get you started, with a source 
> component to test under src/qml and the test file under specs/qml. It should 
> work with both qmltestrunner or a QUICK_TEST_MAIN.
> 
> You don't need IMPORTPATH here. It is used when you want to load a module 
> (only qml files or a cpp plugin), which is defined by a qmldir file (in the 
> attached example it can be for example src/qml/qmldir containing 
> "module qml
> MyRectangle 1.0 MyRectangle.qml")
> 
> Regards,
> Caroline
> 
> 
> 
> 
> ________________________________________
> From: Joshua Kolden [[email protected]]
> Sent: Monday, January 06, 2014 12:40 AM
> To: Alan Alpert
> Cc: Chao Caroline; [email protected]
> Subject: Re: [Development] qtest-qml osx
> 
> On Dec 16, 2013, at 10:44 AM, Alan Alpert <[email protected]> wrote:
> 
>> On Mon, Dec 16, 2013 at 3:47 AM, Chao Caroline <[email protected]> 
>> wrote:
>> 
> 
> 
> Thanks I didn’t realize any of this since the TestCase docs[0] don’t refer to 
> the “Qt Quick Test Reference” docs[1]. Which I would suggest is probably a 
> documentation bug?
> 
> I’ve been able to get the simplest case of this working (despite the docs 
> being very abstract), but I think I’m seeing a bug when used in my project.  
> Can someone please confirm it isn't user error before I log the bug?
> 
> In my environment I have source and tests separated into `src/qml`, and  
> `specs/qml` respectively.
> 
> Regardless if I use the qmltestrunner or a QUICK_TEST_MAIN macro I’m unable 
> to include components from the src/qml path, so unless the tst_*.qml file is 
> actually present in that path no components are loaded. This is true whether 
> I invoke the item with a bare reference, or with `Qt.createComponent()`.
> 
> I’ve tried using the -import command line option as documented, with all 
> variations on absolute and relative paths to the `src/qml` path.  I’ve also 
> tried `IMPORTPATH`, `INCLUDEPATH`, and `QUICK_TEST_SOURCE_DIR` in the test 
> .pro file.
> 
> Production qml files are simply not accessible by tests unless I contaminate 
> the src folder with all the tst_*.qml files (which is a non-starter on this 
> large of a project).
> 
> Thanks,
> j
> 
> 
> [0] - http://qt-project.org/doc/qt-5/qml-qttest-testcase.html
> [1] - http://qt-project.org/doc/qt-5/qtquick-qtquicktest.html
> 
> 
> 
> On Dec 16, 2013, at 10:44 AM, Alan Alpert <[email protected]> wrote:
> 
>> On Mon, Dec 16, 2013 at 3:47 AM, Chao Caroline <[email protected]> 
>> wrote:
>>> Hi,
>>> 
>>> Qt Quick Test is part of Qt (in the qtdeclarative repo). I think the problem
>>> here is that you are trying to run a test using qmlscene directly.
>>> 
>>> QML TestCases should be launched via a C++ harness:
>>> http://qt-project.org/doc/qt-5/qtquick-qtquicktest.html
>>> 
>> 
>> The other alternative is the qmltestrunner utility.
>> 
>> qmlscene is not expected to work, nor planned to, but ideally support
>> will be added to the new qml utility (such support is not currently in
>> place but wouldn't be too hard to add).
>> 
>> --
>> Alan Alpert
>> 
>>> 
>>> 
>>> ________________________________
>>> From: [email protected]
>>> [[email protected]] on behalf of
>>> Joshua Kolden [[email protected]]
>>> Sent: Sunday, December 15, 2013 11:18 PM
>>> To: [email protected]
>>> Subject: [Development] qtest-qml osx
>>> 
>>> We have a fairly large qml project, and with 5.2 we are trying to switch to
>>> TDD for all components (c++, js (coffescript), QML).  Qt Creator and
>>> qmlscene in 5.2 both seem to have the same issue that files are missing:
>>> 
>>>> qmlscene test1.qml
>>> file:///x/d/qt/testDrivenQML/test1.qml:25 Type TestCase unavailable
>>> file:///Users/joshua/Qt5.2.0/5.2.0/clang_64/qml/QtTest/TestCase.qml:45
>>> module "Qt.test.qtestroot" is not installed
>>> 
>>> 
>>> qt-labs/qtest-qml has a merge request under ‘review’ from 2 years ago!!  It
>>> refers to a problem with OSX installation (OSX is our primary development
>>> environment).  I have not been able to test this issue on other platforms,
>>> but noticing that both the merge request and the README install directions
>>> for qtest-qml are both very dated I thought it might be better just to ask
>>> here if this is dead, or is it supposed to work in 5.2 / OSX?  Docs for
>>> TestCase in 5.2 imply that it’ll work the same as any QML Type.
>>> 
>>> Also in a separate note, the new Qt Creator crashes consistently when trying
>>> to create a new qt quick project through the interface.
>>> 
>>> Thanks for the hard work!
>>> 
>>> Best,
>>> j
>>> 
>>> 
>>> _______________________________________________
>>> Development mailing list
>>> [email protected]
>>> http://lists.qt-project.org/mailman/listinfo/development
>>> 
> 
> <example_qmltest.tar.gz>

_______________________________________________
Development mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/development

Reply via email to