Best way to Unit Test Controller Layer

Hi, I was hoping to get the opinion on this matter. My group is currently discussing which method would be the best to Unit test the Controller Layer (using StrutsTestCase). Basically with StrutsTestCase, you can test your Action methods and verify that the action forwards to the correct place, or that certain errors come up. The problem is that these Action classes will make Model layer calls that affect the DB. Whats the best way to test the Action classes? Some possibilities are:
#1) Make a mock model layer that instead of hitting the DB uses a "switch" statement to return the correct value.
#2) Use a test DB to test this. The problem with this is that after running tests, you want to leave the test DB in the same state as when you started the test. This is not very easy to do if your web application only does inserts to the DB. In addition, the Model layer Unit testing will be designed such that it will insert, select, update, select, and delete (in that order), so the state of the DB will remain the same after the test is run (unless JUnit crashes halfway).
#3) Use a copy of a test DB on your local computer. This is beneficial because you can do anything to the DB, and then just delete it because a "master" copy is located elsewhere. The problem with this is, we also hoped to do performance testing of the model layer by running multiple threads of the Model layer unit tests. This won't work now because each thread would make a copy of the master DB....
Thanks for any suggestions you might have!
-L

I have never unit tested just a controller. I have always done end to end testing with the systems I have worked on, so I am coming from a different viewpoint than yourself. I would tend to think that just running a full unit test all the way to your database would be the best test. You will be more likely to find the issues with your program if you are testing with an environment as similar to production as possible.
After running a test you can either purge the data you entered from your test by having sql scripts run against the db, or if this is difficult just reload the database from its original backup. You would probably be able to purge the data quicker than reloading the database from my experience, but it depends on your complexity of the sql scripts.
best of luck.

Similar Messages

  • Best way to Unit test Modules?

    I am working on a Project where the main app is a separate Flex project and then there are several Modules each having their own unit tests. What is the best recommended way of setting up something like this in terms of test runners? I would like to have one test runner that loads all others?

    I have never unit tested just a controller. I have always done end to end testing with the systems I have worked on, so I am coming from a different viewpoint than yourself. I would tend to think that just running a full unit test all the way to your database would be the best test. You will be more likely to find the issues with your program if you are testing with an environment as similar to production as possible.
    After running a test you can either purge the data you entered from your test by having sql scripts run against the db, or if this is difficult just reload the database from its original backup. You would probably be able to purge the data quicker than reloading the database from my experience, but it depends on your complexity of the sql scripts.
    best of luck.

  • Recommended way to unit test mobile cross platform C++ in Visual Studio 2015

    Hello,
    I'm playing with the new Visual Studio 2015 to check its capabilities for cross platform development using C++ as coding language. I've seen several videos in Channel9 about this feature but I don't remember hearing in any of these a word about how
    to unit test such projects from Visual Studio 2015. Is there some recommended way to create unit tests for such projects?
    I'm not sure I can use Visual Studio test projects for C++ to test the android library or the Windows Phone 8.1. If I add a new platform ARM to a test project of those, I cannot select in the platform toolset combo the values that I have for my libraries
    (Clang 3.4 and Windows 8.1 respectively). So it seems that such test projects are not addressed for cross platform c++ in VS2015.
    I also have tried to make a second cross platform library project to contain the tests, adding there the Catch.h file from catch framework or adding the files from Google Test framework. My idea was to link each cross platform test library with their corresponding
    "production code" libraries. In both cases (catch and gtest) I have problems when trying to compile the test framework files (not sure if it is not possible or just my fault being new at C++ for mobile platforms).
    Has anyone succeeded unit testing the cross platform c++ code in VS2015? How?
    Thanks in advance,
    Jorge.

    Hi Jorge,
    Thanks you for posting in MSDN forum.
    Based on your issue, since VS2015 Preview is previews for the next major release of Visual Studio, currently we forums don’t provide support for VS2015 Preview. So the product team would accept the suggestions or feedbacks for the VS2015 now.
    So you can submit the feedback/suggestions to Microsoft Connect feedback portal:
    http://connect.microsoft.com/VisualStudio/feedback/CreateFeedback.aspx, Microsoft engineers will evaluate them seriously. Thanks for your understanding.
    After you submit the feedback, you can post the link here which will be beneficial for other members with the similar issue. And I will help you to vote it.
    Thank you for your understanding.
    Best Regards,
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Best Practices for unit testing an Xlet?

    I'd like to be able to unit test and Xlet using JUnit, but have been stumped by how this can be done correctly.
    The first inclination is that I should mock the XletContext, but that seems to be getting out of control quickly.
    Does anyone have any tips on this they can point me to?
    Thanks.

    Hi Jean-Paul Smit,
    Here is a goog article about how to unit test SQL Server 2008 database using Visual Studio 2010, please see:
    http://blogs.msdn.com/b/atverma/archive/2010/07/28/how-to-unit-test-sql-server-2008-database-using-visual-studio-2010.aspx
    Thanks,
    Eileen
    TechNet Subscriber Support
    If you are
    TechNet Subscription user and have any feedback on our support quality, please send your feedback
    here.

  • What's the best way to store test parameters for future use?

    I'm creating a test stand that will perform various "standard" tests. Each of the tests has it's own setpoints (integer numbers) as well as some string values that are stored in the log file with the data.
    What is the easiest way to store these setpoints and strings so that I can pull them into the VI in the future, say by selecting a test type from a ring control, etc.?
    I would also like to make this dynamic so that new test types can be stored from the vi. (i.e. I don't want to have to hard code all the future tests and their parameters).

    I like INI files, too. If you are looking for an easy way to read and write your parameters to INI, take a look at the Variant Configuration File IO Library of the OpenG Toolkit.

  • Best way to programmatically test opening a pdf

    My company, among other things, uses an image processing library to do complex conversions of various types of content ... including pdfs. Sometimes, this library fails and we are looking for a way to, offline, automate the process of checking whether the pdf file was actually valid. All we really want to do is have one machine which can be triggered at some point after an error occurs to try opening the file and mark a record in our error db indicating if it could be opened or not. Then we can act accordingly.
    I found pdf library but that has a lot more functionality than simply open. Also, the form to get information on this library does not work for me so I am unable to contact any sales reps from adobe. What would someone recommend for this situation and if it is pdf library, can someone tell me how to get the online submission system to work. I tried chrome and safari and neither work (I can't enter the state field in either and the submit via email button does nothing).
    Thanks
    Lee
    PS: If this is not the correct discussion alias, please let me know where to post. There didn't seem to be a dev sdk related disucssion

    In terms of learning more about the "Adobe PDF Library", how to use it and how to license it, you should get in touch with someone at Datalogics (as far as I know Adobe only handles big key account customers themselves when it comes to the Adobe PDF Library).
    Datalogics have a website at http://www.datalogics.com/ and their contact form at http://www.datalogics.com/company/contactus.asp should work just fine. If not, I'd try [email protected] ...
    Olaf

  • Whats the best way to load test?

    So our app is ready for prime time and we are concerned about response times whether we will survive 100 simultaneous users.
    It would be additionally useful if I knew how many users we could tolerate simulataneously.
    I attempted running jmeter but I didn't spend a lot of time with it and it didn't overwhelm me with information.
    I get the sense that I would probably have to spend a couple weeks to really create useful, valid test simulations which I didn't have time for.
    Also, is it even legitimate? The fact that it is one single machine trying to simulate a hundred users on distributed machines?
    So, I really lacked a lot of confidence in my test.
    In fantasyland it would be great, if say there were some distributed google cloud machines that could simulate 100 users and start firing away at my app.
    Starting at 10 users and ramping up until no longer responsive and then providing those results.
    The fact is I don't have a lot of experience with this and would appreciate insight.
    Also, it just occurred to me that this is an internal app inaccessible from outside the organization.
    Does anyone have something they might consider the holy grail of load testing or good advice? Thx.

    If you have money to spend, I would recommend using Oracle's Application Test Suite (ATS) since it is the only test tool I know of that allows you to create a functional test and then convert it to a load test. The capabilities of this tool are pretty amazing considering that it is a single tool where the go to toolset in the past was Win Runner / Load Runner. With Win Runner, you needed 50 machines (or VMs) if you wanted to generate front end load for 50 users. With ATS, you record a script with your browser, and then convert it into a load test. You can adjust things like think time, ramp up time, sustained load, etc.
    What a lot of people miss is that testing tools can be used indefinitely, not just for getting through a migration. If you script your tests appropriately (which means that your user base trusts them), you can use them for every code release because it takes very little effort to run a test script. On top of that, you can set up strategically placed machines around your network that are set up to run a specific test script (think of a common transaction) so that performance metrics can be captured. I worked for a company that had 160 locations around the world and we used our testing tool as a performance monitor in the locations with the worst performance. Having a tool allowed us to see whether our performance issues were related to network, database, app servers, etc. This took the burden of explaining performance issues off of the users. Most users can't really articulate what the problems are anyway (and they aren't expected to).
    If budget is an issue, you can use JMeter from Apache, which will give you the load testing capability but you will miss out on the excellent reporting and management capabilities of the Oracle Application Test Suite.

  • Can I know whether test controller for VS 2010 is installed in TFS

    Hi,
    I downloaded the TestController for VS2010 in client machine & it is an iso file. It asks iso reader to read the file.
    My Question is:
    1.Whether Test Controller 2010 need to configure in TFS server?(Team Foundation Server Administration Console)
    Because I received the following error message while I work in MTM 2010(Lab Center)
    “To create a physical environment, you must have a test controller to available. To add a test controller to your team project collection, you must run the Team Test Controller
    Configuration Tool as an administrator on the computer where your test controller is installed”
    2.While I configure Test Controller 2010 in client machine it shows the
    error message in Configuration Summary dialog box,when "Register with Team Project Collection" in Configuring Test Controller dialog box.
    "Failed to update TFS Team Project Collection as the test Controller service account couldnot be granted required permission.To fix this error,run this tool with an account that has a "Project Collection
    Administrator" rights & try again
    3.Whether Test Controller,Build Controller 2010 & Lab Management need to configure in TFS server?
    Inorder to work in the  Lab Center in MTM2010 & in VS 2010
    regards,
    Nazima

    Hi Nazima,
    According to your description, you are want to create lab environment.
    >> Whether Test Controller 2010 need to configure in TFS server? (Team foundation Server Administration Console)
    No, there isn’t the way to configure test controller in TFS administrator console. You just need to register the test control to TFS.
    >> While I configure Test Controller 2010 in client machine it shows the error message in Configuration Summary dialog box,when "Register with Team Project Collection" in Configuring Test Controller dialog box
    The reason is that the account that you specified in test controller configuration tool haven’t enough permission, the account needs team project collection administrator right.
    # Set Administrator Permissions for Team Project Collections
    https://msdn.microsoft.com/en-us/library/dd547204(v=vs.100).aspx
    >> Whether Test Controller,Build Controller 2010 & Lab Management need to configure in TFS server? Inorder to work in the 
    Lab Center in MTM2010 & in VS 2010
    To register test controller to TFS, please refer to:
    # Setting Up Test Controllers in Lab Environments
    https://msdn.microsoft.com/en-us/library/hh546460.aspx
    About configure build controller, please refer to:
    # Deploy and configure a build controller
    https://msdn.microsoft.com/en-us/library/ee330987.aspx
    About configure lab environment (for SCVMM lab environment), please refer to:
    # Configuring and administering Lab Management
    https://msdn.microsoft.com/en-us/library/dd936084.aspx
    By the way, if you just want to use standard lab environment, you don’t need to configure lab management in TFS administrator console.
    Regards
    Starain
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Best way to edit and deploy pages to remote host.

    Hi All,
    I wasnt sure whether to ask this in General or here.... sorry
    if this is the wrong forum.
    When I make a site using an access database & asp pages
    In the DW I tend to do everything from the remote server.
    I set the site up in my properties and test remotly etc and
    it all works out fine.
    But what I find is remotely it seems to slow up my PC and DW
    hangs quite often when I try to close it down or change sites..
    My problem is I have a connection string for my database and
    Locally the database is just in the root of the site so I used to
    use a Server.mapPath to get my connection..
    But on the remote server My DB is in an outside Private
    directry and my connection string needs the full path to the DB.
    What im finding is if I test locally and upload the
    connection string online chenges to the local connection string and
    I have to go and change it to get the proper paths on the server
    again, even if I choose not to upload dependant files this seems to
    happen.
    Im wondering how you guys do this and if there is anything im
    missing in my set up and the best way to edit test and upload your
    files in DW.
    Thanks again
    Tag

    Hi Envision,
    I tried DSN locally and it worked very well, but not all
    servers support it even if they allow an access database and I have
    found some just allow DSN-Less so plumped to do this that way...
    Thanks ;-)

  • Unit testing legacy code - best approach?

    Hi,
    I've got a project full of legacy code (by this I simply mean untested) and I'm experimenting with retrofitting unit testing to it. I'm sure this entails a great many problems, but here's the first one.
    We have a central class with the Singleton pattern - it's instantiated once and then fetched all over the code. It's a concrete class at the moment, not an interface. Let's call this CentralControl.
    Because the code I want to test relies on the presence of this class, and yet it's too complex/heavyweight to properly instantiate in a test scenario, I need to mock it.
    I guess the ideal way is to turn what's now CentralControl into an interface, and have both a real and mock implementation. The code that enforces the singleton behaviour could have a new method to instantiate the mock version rather than the real thing.
    Would you do this yourself rather than alternatives like extending it, and are there any tools to help automate the process?
    Thanks,
    Rob

    I guess the ideal way is to turn what's now CentralControl into an interface...I think that's the better idea, but you can mock classes as well as interfaces; e.g., EasyMock 2.2.2 and higher.
    ~

  • What's the best way to get user testing of our app (we're based in the UK)

    Hi all.
    We've just developed our first app for Palm and would really like to get some feedback from Palm users (our app allows users to take photos and send them as real printed postcards. We'd be very happy to give users free postcards in exchange for feedback).
    The problem we have is that Palm users are pretty sparse in the UK. We've found that user testing with non-Palm users becomes handset testing rather than app testing. We have to teach them how to use Palm ("Where's the back button?") and so the testing mainly focuses on the particularities of Palm rather than our app. Plus, we don't benefit from the user being able to compare to other Palm apps.
    Any advice on the best way to get feedback from Palm users? Especially as they'll need to download the SDK and install our app using it in order to get it onto their phones.
    If any of the users of this forum are interested in giving the app a go and sending us feedback, I'd love to send you the IPK and then chat. Just send me an email using [email protected]
    Our app is available for Pixi+, Pre+ and Pre2.
     Thanks,
     Freddie.
    Post relates to: Pixi Plus p121ueu (SFR)

    Hello freddie:
    Welcome to the Palm Forums. Thank You for the offer. I highly suggest offering it up
    to our many enthusiasts on Twitter as a beta with the #webos hashtag or joining
    the Precentral.net community and list it in a topic there, homebrew beta. You would
    get better beta response if you Package your app and put it in an ipk to simplify
    the install.
    Hope that helps... Best of luck with your app!
    notimeoff

  • Whats the best way to get a copy of a clients DB onto an internal test DB?

    Hi there
    We have a client who hosts an Oracle 9i DB in house and we need to get a copy of this DB onto our own servers for testing purposes. What is the best way to go about doing this?
    I was reading about the data pump for exporting and importing [http://www.exforsys.com/tutorials/oracle-10g/oracle-10g-using-data-pump-export.html]
    Would this meet my requirements and how easy is it to do? Also what type of export would I need to do (there a 5+ schemas using different tablespaces)
    Sorry if this is all a bit vague, but i am not a DBA and have been tasked with doing this :(
    Thanks in advance,
    Toby
    edit: sorry i meant a 9i DB
    Edited by: redeye on Nov 5, 2009 11:21 AM

    If you want to export schemas/objects from 9i db you wouldn't be able to use datapump for exporting them,although you can import the dump file that will be created using the datapump.
    Determine what schemas you need at the test(destination) database, and then export them from the source(clients db) database.
    Also make sure that on the target database server, os paths where the oracle related files will be created(redo logs,datafiles...) are the same as the ones that are on the source database.

  • Best way to transfer application from Test Environment to Dev. Environment

    Hi All,
    We are try to create an application on Hosted Environment similar to www.apex.oracle.com.
    We got two work space
    1. app_production
    2. app_test
    My application will have 200+ tables and many other supporting object.
    My question is in hosted environment what is the best way to copy application from test to production environment (P.S In hosted environment I can uses SQL Developer / TOAD or any other tool .. its similar to www.apex.oracle.com)
    With my present workaround I have to use
    Go to Utilites -> Generate DLL
    and then export this and application..
    The main problem is 200+ table and associated structures .. its very difficult to keep track ...
    Can anyone suggest me any good way for HOSTED ENVIRONMENT

    Hi,
    Just an idea:
    1 - Do a DDL export of the source env
    2 - Do a DDL export of the target env
    3 - Use some tool to compare those files and highlight the differences. There are even some tools that are smart enough to generate SQL statements to apply the differences in the target env.
    I hope this helps.
    Luis

  • Best way to update through testing repo

    As I am finding out, there are certain limitations to pacman. I enabled the testing repo to try out xorg 1.7, and to see if this could help with my X delay at startup. I enabled the repo and installed xorg, gcc, and among other packages. My problem is, I dont want the testing repo enabled by default. So I comment out testing from my pacman.conf, and now I cannot upgrade without dependency errors.
    Should I have used the ABS to install xorg 1.7...? Now I would like to disable the testing repo and be able to still sync and upgrade as normal. Am I missing something here...? Since I upgraded all packages from the testing repo, and now all my revisions are newer, and when I disable the repo to prevent any other updates, I am now unable to upgrade normally...  So... what is the best way to upgrade through the testing repo..?
    Last edited by StanIsTheMan (2009-10-23 10:15:00)

    Allan wrote:
    You can revert all packages to versions in [core]/[extra] by using "pacman -Suu".  Otherwise, you need to wait for these to move out of [testing].
    What problems are you observing?
    I didn't necessarily want to downgrade all of the packages I upgraded through the testing repo. It was after upgrading the packages from the testing repo, and then commenting out the "testing"  in pacman.conf, and then trying a normal 'pacman -Su'. I was then receiving errors on dependencies that were not met, and was refusing an upgrade. (which i can understand, since the testing db is being ignored, and the revision numbers are different and would cause conflicts)
    I have reverted back to the earlier versions from the upgrade with a 'pacman -Suu'  Now what is the proper way to upgrade just xorg..? Should I use the ABS..? I dont want to enable the testing repo, because if I do, It wants to pull in all of the testing branch that I dont want. So really my original question is... What is the bet way, or proper way to upgrade a package from the testing branch...?
    Last edited by StanIsTheMan (2009-10-23 10:40:00)

  • What is the best way to port complete applications from DEV - Test - PRD?

    Hi,
    One of my customers recently asked me, Supposing I do the complete integrations and modelling in SOA Suite on the DEV Environment. Then,
    What is the best way to port complete applications from DEV -> Test -> PROD ??
    Also, since the URLs in use in the DEV environment would be very different from other environments, what is the easiest way to maintain them, and to build in Access Control mechanisms ?
    Best Regards

    Hi AJ,
    Nice PDF !
    Though the PDF does give a basic idea as to how we can go about the deployments using ANT and EM in Test and Prod, it doesn't really give extensive details. For eg. ANT would obviously need huge ANT scripts to be written for migrations to multiple Test servers, etc.
    Similarly, when we talk about EM, does it mean each of the services has to be manually deployed on Production ?
    I am sure we would be looking more towards a fully automated solution. No ?
    Best Regards
    Nitin

Maybe you are looking for

  • Settings and usage of external FTP Server in ECC 6.0

    Dear all, I work in ECC 6.0, and I want to configure and use an external FTP Server for upload, download and delete file from FTP Server. My questions are: 1) Which are steps for configure an FTP connection? 2) How can I read, delete and send a flat

  • Anyone know what is this?

    Interval Since Last Panic Report:  44248 sec Panics Since Last Report:          4 Anonymous UUID:                    D73EBFEF-1FC1-462E-B11A-2A3968232F71 Sun Sep  2 16:31:30 2012 panic(cpu 0 caller 0xffffff7f80918947): NVRM[0/1:0:0]: Read Error 0x000

  • Macbook Pro Will Not Boot Windows Disk

    I have a late 08 (or early 09) Unibody Macbook Pro 2.53Ghz. I start the Bootcamp Assistant and successfully create my Windows partition. When I restart with the Windows 7 disk, I get a blinking cursor for 1 second then it goes to a black screen and n

  • Home Hub 3 A.. BT's best ever home hub?

    Hi, I signed up for Infinity 2 (coming from sky) on the 31st May.  I timed it just before the line rental increase (yay) but also just before the home hub 4 was being supplied by default to new customers (doh).   On sign up BT clearly advertised they

  • IPhone 4s: No service and will not restore.

    For about ten hours today, my phone has consistently said that it's had no service and so I've gone the day without a way of calling or texting. Considering how inconvenient that is, I tried every troubleshooting tip on this site that was available a