Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to test QUdpSocket object
Forum Updated to NodeBB v4.3 + New Features

How to test QUdpSocket object

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 5 Posters 1.0k Views 3 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.
  • D Offline
    D Offline
    dwilliams
    wrote on last edited by
    #1

    I'm writing an object to send data via udp to a statsd endpoint. I have the the sendUDP method written and it returns the number of bytes sent so I can test the length of the data against the length sent in my unit test.

    Is there a way for the unit test to set up a udp socket client and verify the data arrives. I understand that UDP is not guaranteed delivery. But, in a unit test between a machine and itself, it should be generally reliable. I'm just exploring the options.

    The challenge in what I've looked at before is that the receiving is done via sockets and signals and is out-of-line from the unit test that sends the data.

    Any suggestions or hints would be appreciated.

    Gojir4G 1 Reply Last reply
    0
    • D dwilliams

      I'm writing an object to send data via udp to a statsd endpoint. I have the the sendUDP method written and it returns the number of bytes sent so I can test the length of the data against the length sent in my unit test.

      Is there a way for the unit test to set up a udp socket client and verify the data arrives. I understand that UDP is not guaranteed delivery. But, in a unit test between a machine and itself, it should be generally reliable. I'm just exploring the options.

      The challenge in what I've looked at before is that the receiving is done via sockets and signals and is out-of-line from the unit test that sends the data.

      Any suggestions or hints would be appreciated.

      Gojir4G Offline
      Gojir4G Offline
      Gojir4
      wrote on last edited by Gojir4
      #2
      This post is deleted!
      jsulmJ 1 Reply Last reply
      0
      • Christian EhrlicherC Online
        Christian EhrlicherC Online
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on last edited by
        #3

        You're looking for https://doc.qt.io/qt-5/qtest.html#qWaitFor

        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
        Visit the Qt Academy at https://academy.qt.io/catalog

        1 Reply Last reply
        3
        • Kent-DorfmanK Offline
          Kent-DorfmanK Offline
          Kent-Dorfman
          wrote on last edited by
          #4

          @dwilliams said in How to test QUdpSocket object:

          Is there a way for the unit test to set up a udp socket client and verify the data arrives. I understand that UDP is not guaranteed delivery. But, in a unit test between a machine and itself, it should be generally reliable. I'm just exploring the options.

          ncat utility...

          https://serverfault.com/questions/207683/listen-to-udp-data-on-local-port-with-netcat

          and if the data is binary then pipe the output to "od -cx"

          1 Reply Last reply
          0
          • Christian EhrlicherC Online
            Christian EhrlicherC Online
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @Kent-Dorfman said in How to test QUdpSocket object:

            ncat utility...

            In an unit test? Not very useful....

            Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
            Visit the Qt Academy at https://academy.qt.io/catalog

            1 Reply Last reply
            0
            • Kent-DorfmanK Offline
              Kent-DorfmanK Offline
              Kent-Dorfman
              wrote on last edited by
              #6

              by the wikipedia defintiion of unit testing I don't see a problem.

              In computer programming, unit testing is a software testing method by which individual units of source code, sets of one or more computer program modules together with associated control data, usage procedures, and operating procedures, are tested to determine whether they are fit for use.

              1 Reply Last reply
              0
              • Gojir4G Gojir4

                This post is deleted!

                jsulmJ Offline
                jsulmJ Offline
                jsulm
                Lifetime Qt Champion
                wrote on last edited by
                #7

                @Gojir4 I would say this while loop is blocking the event loop.

                https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                1

                • Login

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