locked
unit testing for LightSwitch RRS feed

  • Question

  • How will LightSwitch interact with unit tests?
    Thursday, August 26, 2010 10:28 AM

Answers

  • Though it may be possible, this is not something we currently have planned for in V1. We are open to feedback and are interested to hear what scenarios you find most important.

    Thanks,
    Erik Cutts


    This posting is provided "AS IS" with no warranties, and confers no rights.
    Friday, October 8, 2010 6:25 PM

All replies

  • Though it may be possible, this is not something we currently have planned for in V1. We are open to feedback and are interested to hear what scenarios you find most important.

    Thanks,
    Erik Cutts


    This posting is provided "AS IS" with no warranties, and confers no rights.
    Friday, October 8, 2010 6:25 PM
  • Now that most of us have taken the cover off of Logical View, I would at least want to Unit Test any of the additional classes I may have written by hand (for Globals extensions, etc.) or via Write Code. So my question would be, could we do this in a Unit Test Proect and what references would we need in our unit test project to access these manual or LS-built classes?
    If you believe that I've answered your question, please remember to mark it as answered.

    MicroApplications, Inc. -- Information Systems Integration and Custom Software Development
    Friday, October 8, 2010 6:29 PM
  • Eric,

    It seems to be very difficult, if not impossible, to unit test any user code written by the developer in LS.

    Surely if LS is written using  a number of "best practices" being able to unit test custom code would be one of them.

    I've added a unit test project to the solution containing my LS project, but even though I've added a rerefence to my LS project from my test project, I can't seem to get the business objects to resolve to test the code that I've added to them, let alone attempt any kind of TDD.

    This is *not* good, & is a big step backwards. I hope this is only a V1 limitation, but it kind of looks like unit testing was forgotten when the architecture for LS was created. Don't get me wrong, I'm loving LS, but not being able to unit test at all is a big negative.

    I would dearly love to be able to TDD my LS code into existance, but if not, I'd at least want to be able to unit test it.

    Thanks,

    Yann

    Monday, February 28, 2011 3:42 AM
  • Eric,

    I've finally managed to get a unit test class library to "see" the Entities in my LS app (but I had to add a file reference to MyApp.Common.dll, I couldn't add a project reference), but when I new one up in a test, so that I can do something as simple as verify that a property exists on that entity, I get the following error:

    "A new instance of the EntityObject class cannot be initialized because the ambient IDataWorkspace is not available. Please use the constructor that specifies an EntitySet."

    Ok, so I do as it says & pass a new EntitySet(of MyEntity) to the constructor of MyEntity, now I get a different error:

    "The Main Dispatcher has not been initialized."

    How do I get around this to be able to perform such simple test on my entities?

    Thanks,

    Yann

    Thursday, March 17, 2011 12:07 AM
  • Again, we're not making it "easy" for people to do this in V1, and it's a limitation that we hope to address in future versions.

    That said, I got to the same place as you with test-projects and have poked around our unit-test infrastructure which is not based on VSTS.  I have not yet been able to get it to work locally with VSTS test projects.  I think it is possible but you'll need to setup a dispatcher and Application Data Contexts.

    Right now we're working hard to get V1 out the door. I'm sure we'll have more on this soon. 


    This posting is provided "AS IS" with no warranties, and confers no rights.
    Monday, March 21, 2011 11:49 PM
  • Hi Erik,

    Thanks. It's good to hear you plan to address unit testing in future versions. EF finally managed to get to the point of having POCO unit-testable entities, it seems like such a huge step backward to not be able to unit test at all.

    I'm not using VSTS either, I'm using NUnit.

    So far all I've been able to do is pull most of the business logic out into a dll & call it from entities/test it from there.

    Yann

    PS - it is just me, or has MSDN forum alerts stopped working? I'm not getting ANY alerts for ANY posts I've marked as "alert me".

    Tuesday, March 22, 2011 12:46 AM
  • Good idea pulling the logic out and testing it there.

    It seems Alerts are broken. We're working with the MSDN folks to get them fixed ASAP. Bad timing for us just releasing Beta2. Meanwhile we mark threads as "alert me" so there is at least some way to pick them out of the list and come back often.


    This posting is provided "AS IS" with no warranties, and confers no rights.
    Tuesday, March 22, 2011 6:22 PM
  • Hi

    I was also thinking of putting the business logic as much as possible in separate assembly(s).

    Not only for UnitTest reasons but for better structuring, managability(versioning...), reusability and distributed development(many developers)

    If anyone has an advice or real world experience concerning LS and maintainability (beyond testing) that would be great.

    Is there a necessity or a good way or is it even possible to apply ui automation (automated) testing?

     

    Best regards

    Stefan

     

    PS LS looks really good so far and I am evaluating it at the moment for an upcoming bigger project

    Thursday, May 12, 2011 2:15 AM
  • Hi Yann, 

        I was also facing the same issue at one instance but using

    this.TimeTableProperty = this.DataWorkspace.ApplicationData.TimeTables.AddNew();

    instead of 

    this.TimeTableProperty = new TimeTable();

    Workd for me.

    Hope it allows you to go ahead & create your new object.

    Thanks & Regards

     

     

     


    Supreet
    Saturday, June 18, 2011 9:14 AM
  • Ahh OK, thanks for that Supreet!

    Yann

    (plus ça change, plus c'est la même chose!)

    Tuesday, July 5, 2011 12:44 AM
  • @Yann, I continue to daily mark all posts as having been read rather than rely on the sometimes erratic alert email functionality. 
    Thursday, July 7, 2011 12:58 AM
  • I've been thinking about building a data driven "system" test system that goes beyond unit testing.

    Basically, emulating user input for a series of screens and comparing the results to preset values stored in a database.

    A Screen would have collection values filled by code and compare the expected database values - emulating a user.

    I'm going to think about this more . . . the correctness of the application event coding within an LS solution needs to be tested constantly. 

    We should probably take a RWA and discuss best practices for unit and (larger) system testing.

    Thursday, July 7, 2011 1:09 AM