Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Suite Grouping #27

Merged
merged 11 commits into from
Sep 2, 2019
Merged

Add Suite Grouping #27

merged 11 commits into from
Sep 2, 2019

Conversation

timhall
Copy link
Member

@timhall timhall commented Aug 30, 2018

The goal here is that reporters only take in a single TestSuite, but for added flexibility TestSuite can contain any number of arbitrarily nested TestSuite groups. This should simplify the API for WorkbookReporter and allow different ways of defining tests.

Dim Suite As New TestSuite
Suite.Name = "Project Name"

' BeforeEach / AfterEach called for all tests
Fixture.ListenTo Suite

With Suite.Group("Module Name")
  With Suite.Group("Part 1")
    ' BeforeEach / AfterEach just for "Part 1"
    Part1Fixture.ListenTo .Self

    With .Test("Test 1")
      .IsEqual 2 + 2, 4
    End With
  End With
End With

This allows for separating tests and suites among different functions / files.

Dim Suite As New TestSuite
Suite.Name = "Project Name"

ModuleA.Tests Suite.Group("Module A")

With Suite.Group("Module B")
  ModuleB.Test1 .Test("Test 1")
  ModuleB.Test2 .Test("Test 2")
End With


''
' (Optional) description of suite for display in runners
'
' @property Description
' @type String
''
Public Description As String
Public Name As String
Copy link
Contributor

@connerk connerk Aug 30, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do you think about keeping Description as a property, for backwards compatibility.

Public Property Get Description() as String
     Debug.Print "The Property ""Description"" has been deprecated. Use ""Name"" instead."
     Description = Name
End Property
Public Property Let Description(NewDescription as String)
     Debug.Print "The Property ""Description"" has been deprecated. Use ""Name"" instead."
     Name = NewDescription
End Property

this would reduce the need to alter existing code for a semantic name change.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@connerk
Copy link
Contributor

connerk commented Oct 1, 2018

I can't get blocks to build...

@connerk
Copy link
Contributor

connerk commented Oct 2, 2018

The current test suite doesn't test WorkbookReporter which is labeled at the top as a primary benefactor of the changes.

I've tried altering the Tests.RunTests() a bit to wedge everything into a single test suite but can't seem to get the syntax right.

so far, a couple different directions that seem logical but don't work:

Public Function RunTests() As TestSuite
    
    Dim wbr As New WorkbookReporter
    wbr.ConnectTo ThisWorkbook.Sheets(1)
    wbr.Start 1
    
    wbr.Output NestedTests
    
    wbr.Done
End Function


Private Function NestedTests() As TestSuite
    Dim ts As New TestSuite
    ts.Name = "RunTests"
    
    Dim TCase As TestCase
    
    With ts.Group("TestSuite Tests")
        Dim TTS As TestSuite
        Set TTS = Tests_TestSuite.Tests
        
        For Each TCase In TTS.Tests
            .Test(TCase.Name).Self = TCase
        Next TCase
        
        
    End With
    With ts.Group("TestCase Tests")
        Dim TTC As TestSuite
        Set TTC = Tests_TestCase.Tests
        
        For Each TCase In TTS.Tests
            TCase .Test(TCase.Name)
        Next TCase
    
    End With
    
    Set NestedTests = ts
    
End Function

sorry! trying to be helpful and contribute. how can I get this tested before approving the PR?

Thanks Tim!

@timhall
Copy link
Member Author

timhall commented Sep 2, 2019

Temporarily removed WorkbookReporter, will add it back in a later PR

@timhall timhall merged commit 56a1334 into master Sep 2, 2019
@timhall timhall deleted the group branch September 2, 2019 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants