rubberduck-vba / Rubberduck

Every programmer needs a rubberduck. COM add-in for the VBA & VB6 IDE (VBE).
https://rubberduckvba.com
GNU General Public License v3.0
1.91k stars 299 forks source link

Doing the first install. found a guide to use (from RB). Set up a Test Module. When I run TestExplorer, the ducks just go round and round #5906

Closed skorpio07 closed 2 years ago

skorpio07 commented 2 years ago

Rubberduck version information

Version 2.5.2.5906 OS: Microsoft Windows NT 10.0.19042.0, x64 Host Product: Microsoft Office x86 Host Version: 16.0.14527.20234 Host Executable: EXCEL.EXE

I let it run overnight (knowing that it would not stop spinning). Don't know what I am doing wrong. The info below can be copy-paste-completed from the first lines of Rubberduck's log or the About box:

Rubberduck version [...]
Operating System: [...]
Host Product: [...]
Host Version: [...]
Host Executable: [...]

Description A clear and concise description of what the bug is.

To Reproduce Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Logfile Rubberduck generates extensive logging in TRACE-Level. If no log was created at %APPDATA%\Rubberduck\Logs, check your settings. Include this log for bug reports about the behavior of Rubberduck.

Additional context Add any other context about the problem here.

retailcoder commented 2 years ago

Related: https://stackoverflow.com/q/70147500/1188513

Can you please elaborate a bit on the steps to reproduce the problem, and confirm that your test module has at least one unit test?

Obviously something is wrong if the toolwindow's "busy" state is erroneously set (or erroneously not reset), but the spinning duckies would only be shown while parsing / discovering tests. How was the parse triggered exactly?

skorpio07 commented 2 years ago

I will check this when i get home (RD on laptop). but all i did was add the Sub (with comment) to TestModule1 and then run TestExplorer. Didn't change any settings.

On Tue, Nov 30, 2021 at 4:57 PM Mathieu Guindon @.***> wrote:

Related: https://stackoverflow.com/q/70147500/1188513

Can you please elaborate a bit on the steps to reproduce the problem, and confirm that your test module has at least one unit test?

Obviously something is wrong if the toolwindow's "busy" state is erroneously set (or erroneously not reset), but the spinning duckies would only be shown while parsing / discovering tests. How was the parse triggered exactly?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/rubberduck-vba/Rubberduck/issues/5906#issuecomment-983056020, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAIKEIL2IY5OR4OOO7VUF4LUOVCEVANCNFSM5JCYQNPA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

BZngr commented 2 years ago

FWIW, Another path that reliably generates constantly spinning ducks.

  1. Open Code Inspections window
  2. Open Test Explorer
  3. Run a single test or a group of tests.
  4. Code Inspections window presents constantly spinning ducks after the test(s).

Work around:

  1. Close Code Inspections window (Test Explorer can remain open or be closed)
  2. Manually initiate a Parse using the 'Ready' button.
  3. After the manually initiated Parse is finished. Open Code Inspections...all is well.
skorpio07 commented 2 years ago

BZngr

So I opened Code Inspections and it displayed with data (read a few errors, seemed accurate). So I closed it. then i tried to find the Ready button but don't see it. The toolbar says Parse Error with a red X. is that where the Ready button is? So Idid a refresh and it went through several steps, still parsing at the moment.

skorpio07 commented 2 years ago

Finally got it to say ready (probably by going to settings and excluding a number of add-ins). So now I click` Refresh, the ducks spin and a few seconds later they disappear. then I run Test Explorer, click Refresh and nothing appears in the window. summary says 0 of 0 test run. I can't click the Run button or the Add button. what do i need to do to run my test.

`Option Explicit Option Private Module

'@TestModule '@Folder("Tests")

Private Assert As Object Private Fakes As Object

'@ModuleInitialize Private Sub ModuleInitialize() 'this method runs once per module. Set Assert = CreateObject("Rubberduck.AssertClass") Set Fakes = CreateObject("Rubberduck.FakesProvider") End Sub

'@ModuleCleanup Private Sub ModuleCleanup() 'this method runs once per module. Set Assert = Nothing Set Fakes = Nothing End Sub

'@TestInitialize Private Sub TestInitialize() 'This method runs before every test in the module.. End Sub

'@TestCleanup Private Sub TestCleanup() 'this method runs after every test in the module. End Sub

Public Sub testme()

'@TestMethod

Dim x, y

x = 1

y = 1

If x = y Then MsgBox ("Equal") Else MsgBox ("Not Equal") End If

End Sub `

BZngr commented 2 years ago

@skorpio07

The quick answer is that the attribute `@TestMethod needs to precede the Sub declaration. Try editing your test to match the following:

'@TestMethod("Uncategorized")
Private Sub testme()
    Dim x, y
    x = 1
    y = 1

    If x = y Then
         MsgBox ("Equal")
    Else
        MsgBox ("Not Equal")
    End If

End Sub

Once you can run the above test...

The longer answer - or things to consider/try:

  1. RD can insert a TestMethod for you. The Test Explorer's Add button dropdown will enable a TestMethod button once you have a RD test module loaded in the VBE editor. The inserted subroutine will include some structure to help organize your test(s). See an example below.
  2. Avoid MsgBox or any other UI pop-up interactions within tests. I know you are just trying to get a test to run ATM...just felt compelled to mention it :).

RD Generated TestMethod

'@TestMethod("Uncategorized")
Private Sub TestMethod1()                        'TODO Rename test
    On Error GoTo TestFail

    'Arrange:

    'Act:

    'Assert:
    Assert.Succeed

TestExit:
    Exit Sub
TestFail:
    Assert.Fail "Test raised an error: #" & Err.Number & " - " & Err.Description
    Resume TestExit
End Sub
skorpio07 commented 2 years ago

Excellent answer. When I get back to computer I will implement it. Getting close. Fyi, this is the third try of RB. Thanks for your help.

On Sat, Dec 4, 2021, 9:40 AM Brian Zenger @.***> wrote:

@skorpio07 https://github.com/skorpio07

The quick answer is that the attribute @.*** needs to precede the Sub declaration. Try editing your test to match the following:

@.***("Uncategorized") Private Sub testme() Dim x, y x = 1 y = 1

If x = y Then
     MsgBox ("Equal")
Else
    MsgBox ("Not Equal")
End If

End Sub

Once you can run the above test...

The longer answer - or things to consider/try:

  1. RD can insert a TestMethod for you. The Test Explorer's Add button dropdown will enable a TestMethod button once you have a RD test module loaded in the VBE editor. The inserted subroutine will include some structure to help organize your test(s). See an example below.
  2. Avoid MsgBox or any other UI pop-up interactions within tests. I know you are just trying to get a test to run ATM...just felt compelled to mention it :).

RD Generated TestMethod

@.***("Uncategorized") Private Sub TestMethod1() 'TODO Rename test On Error GoTo TestFail

'Arrange:

'Act:

'Assert:
Assert.Succeed

TestExit: Exit Sub TestFail: Assert.Fail "Test raised an error: #" & Err.Number & " - " & Err.Description Resume TestExit End Sub

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/rubberduck-vba/Rubberduck/issues/5906#issuecomment-986038374, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAIKEINB5X76MECPMAHH4WTUPIR53ANCNFSM5JCYQNPA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

skorpio07 commented 2 years ago

ok, this can be closed (which I will do). got the test module to pass, tested various things. now I need to read (alot) to get up to speed on some of the lingo. do you have any book titles that you could recommend that would cover the concepts in your program?

thanks again

Vogel612 commented 2 years ago

While there is no book out there (at least to my knowledge), you should find a lot of the information you need on the website (https://rubberduckvba.com - which should be finishing it's reconstruction any day now :smile:) as well as on the wordpress site where Mathieu (and a few other contributors) blog: https://rubberduckvba.wordpress.com