簡體   English   中英

嘗試使用robotframework進行測試時,Swing應用程序未啟動

[英]Swing Application not launching when trying to test with robotframework

我正在嘗試使用robotframework的swing庫在基於swing的java應用程序上運行一些自動化測試。 我想我已經安裝了所有庫。 但是,當我運行測試時,它實際上無法正確啟動應用程序(即失敗測試),並且在測試真正開始之前,我會收到很多警告(?)。 另外,我會短暫地看到Java圖標出現在擴展塢上,但是實際上沒有窗口打開。

在這里測試演示應用程序沒有任何問題。 很好

以下是我的機器人腳本:

*** settings ***
Library  SwingLibrary

*** Test Cases ***
Test Push Button
    Start Test Application

*** Keywords ***
Start Test Application
    Start Application  com.xyz.app.ui.MainFrame
    Select Main Window

這是輸出:

    davids$ sudo CLASSPATH=lib/swinglibrary-1.5.1.jar:app.jar jybot app.robot
Password:
10:31:34.578 [MainThread] DEBUG o.p.n.u.i.l.InternalLoggerFactory - Using SLF4J as the default logging framework
10:31:34.613 [MainThread] DEBUG o.p.n.u.internal.PlatformDependent0 - java.nio.Buffer.address: available
10:31:34.613 [MainThread] DEBUG o.p.n.u.internal.PlatformDependent0 - sun.misc.Unsafe.theUnsafe: available
10:31:34.614 [MainThread] DEBUG o.p.n.u.internal.PlatformDependent0 - sun.misc.Unsafe.copyMemory: available
10:31:34.615 [MainThread] DEBUG o.p.n.u.internal.PlatformDependent0 - java.nio.Bits.unaligned: true
10:31:34.616 [MainThread] DEBUG o.p.n.u.internal.PlatformDependent - Java version: 8
10:31:34.616 [MainThread] DEBUG o.p.n.u.internal.PlatformDependent - -Dio.netty.noUnsafe: false
10:31:34.616 [MainThread] DEBUG o.p.n.u.internal.PlatformDependent - sun.misc.Unsafe: available
10:31:34.617 [MainThread] DEBUG o.p.n.u.internal.PlatformDependent - -Dio.netty.noJavassist: false
10:31:34.697 [MainThread] DEBUG o.p.n.u.internal.PlatformDependent - Javassist: available
10:31:34.698 [MainThread] DEBUG o.p.n.u.internal.PlatformDependent - -Dio.netty.tmpdir: /var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/T (java.io.tmpdir)
10:31:34.698 [MainThread] DEBUG o.p.n.u.internal.PlatformDependent - -Dio.netty.bitMode: 64 (sun.arch.data.model)
10:31:34.698 [MainThread] DEBUG o.p.n.u.internal.PlatformDependent - -Dio.netty.noPreferDirect: false
10:31:34.698 [MainThread] DEBUG o.p.n.buffer.PooledByteBufAllocator - -Dio.netty.allocator.numHeapArenas: 4
10:31:34.699 [MainThread] DEBUG o.p.n.buffer.PooledByteBufAllocator - -Dio.netty.allocator.numDirectArenas: 4
10:31:34.699 [MainThread] DEBUG o.p.n.buffer.PooledByteBufAllocator - -Dio.netty.allocator.pageSize: 8192
10:31:34.699 [MainThread] DEBUG o.p.n.buffer.PooledByteBufAllocator - -Dio.netty.allocator.maxOrder: 11
10:31:34.699 [MainThread] DEBUG o.p.n.buffer.PooledByteBufAllocator - -Dio.netty.allocator.chunkSize: 16777216
10:31:34.699 [MainThread] DEBUG o.p.n.buffer.PooledByteBufAllocator - -Dio.netty.allocator.tinyCacheSize: 512
10:31:34.699 [MainThread] DEBUG o.p.n.buffer.PooledByteBufAllocator - -Dio.netty.allocator.smallCacheSize: 256
10:31:34.699 [MainThread] DEBUG o.p.n.buffer.PooledByteBufAllocator - -Dio.netty.allocator.normalCacheSize: 64
10:31:34.699 [MainThread] DEBUG o.p.n.buffer.PooledByteBufAllocator - -Dio.netty.allocator.maxCachedBufferCapacity: 32768
10:31:34.699 [MainThread] DEBUG o.p.n.buffer.PooledByteBufAllocator - -Dio.netty.allocator.cacheTrimInterval: 8192
10:31:34.720 [MainThread] DEBUG o.p.n.c.MultithreadEventLoopGroup - -Dio.netty.eventLoopThreads: 8
10:31:34.768 [MainThread] DEBUG o.p.netty.channel.nio.NioEventLoop - -Dio.netty.noKeySetOptimization: false
10:31:34.768 [MainThread] DEBUG o.p.netty.channel.nio.NioEventLoop - -Dio.netty.selectorAutoRebuildThreshold: 512
==============================================================================
app                                                                          
==============================================================================
Test Push Button                                                      | FAIL |
com.xyz.app.ui.MainFrame
------------------------------------------------------------------------------
app                                                                   | FAIL |
1 critical test, 0 passed, 1 failed
1 test total, 0 passed, 1 failed
==============================================================================
Output:  /Users/davids/swinglibrary-demo/output.xml
Log:     /Users/davids/swinglibrary-demo/log.html
Report:  /Users/davids/swinglibrary-demo/report.html

另外,我已經驗證了app.jar文件確實包含MainFrame類的路徑:com / xyz / app / ui / MainFrame.class

更新:使用“在單獨的線程中啟動應用程序”關鍵字而不是“啟動應用程序”給出了一個新的錯誤。 似乎找不到主類,即使我通過解壓縮jar文件手動確認了主類的路徑也是如此:

Exception in thread "Thread-14" java.lang.RuntimeException: java.lang.ClassNotFoundException: com.xyz.app.ui.MainFrame at org.robotframework.swing.keyword.launch.ApplicationLaunchingKeywords$1.run(ApplicationLaunchingKeywords.java:53) at java.lang.Thread.run(Thread.java:745) Caused by: java.lang.ClassNotFoundException: com.xyz.app.ui.MainFrame at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:264) at org.robotframework.swing.keyword.launch.ApplicationLaunchingKeywords.getMainMethod(ApplicationLaunchingKeywords.java:64) at org.robotframework.swing.keyword.launch.ApplicationLaunchingKeywords.launchApplication(ApplicationLaunchingKeywords.java:32) at org.robotframework.swing.keyword.launch.ApplicationLaunchingKeywords$1.run(ApplicationLaunchingKeywords.java:51) ... 1 more

以下解決了這個問題:

  • 使用export設置CLASSPATH而不是內聯定義。
  • 使用.jars的完整路徑。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM