Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QtCreator doesn't recognize Qt Quick Unit Tests
Qt 6.11 is out! See what's new in the release blog

QtCreator doesn't recognize Qt Quick Unit Tests

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 1 Posters 491 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    begun
    wrote on last edited by
    #1

    I am trying to write QML unit tests in my Qt6 project. Here is my project structure:

    | CMakeLists.txt
    | MyProject
    | - qml
        | - qml.qrc
            |- /qml
                |- MyButton.qml
            |- /test
                |- tst_mybutton.qml
    

    MyButton.qml defines a RoundButton, nothing complex. The button is working as expected when I run my application.

    Now I'd like to write a unit test to automatically test MyButton. Here is tst_mybutton.qml, which QtCreator initialized for me:

    import QtQuick
    import QtTest
    
    TestCase {
        name: "MyButton"
    
        function test_onClick() {
            // TODO
            verify(true);
        }
    }
    

    At the moment, this is just a stub. My problem is that QtCreator does not recognize this as a unit test. The test results tab is empty, and every option in the Tools > Test menu is greyed out (with the exception of "Rescan Tests", which doesn't seem to do anything).

    Can someone please help me understand what's going on here? Why won't QtCreator run my unit test?

    B 1 Reply Last reply
    1
    • B begun

      I am trying to write QML unit tests in my Qt6 project. Here is my project structure:

      | CMakeLists.txt
      | MyProject
      | - qml
          | - qml.qrc
              |- /qml
                  |- MyButton.qml
              |- /test
                  |- tst_mybutton.qml
      

      MyButton.qml defines a RoundButton, nothing complex. The button is working as expected when I run my application.

      Now I'd like to write a unit test to automatically test MyButton. Here is tst_mybutton.qml, which QtCreator initialized for me:

      import QtQuick
      import QtTest
      
      TestCase {
          name: "MyButton"
      
          function test_onClick() {
              // TODO
              verify(true);
          }
      }
      

      At the moment, this is just a stub. My problem is that QtCreator does not recognize this as a unit test. The test results tab is empty, and every option in the Tools > Test menu is greyed out (with the exception of "Rescan Tests", which doesn't seem to do anything).

      Can someone please help me understand what's going on here? Why won't QtCreator run my unit test?

      B Offline
      B Offline
      begun
      wrote on last edited by
      #2

      @begun Any ideas? I'd love some help here.

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved