Better UI for Unit Tests

I've been doing a lot of unit tests lately.  Right now I'm working on a code converter Air app and I'm constantly creating unit tests for bugs I'm finding and running them, and debugging them when they don't work.  When I debug, it's easiest to isolate the runner to run only one test.  I know I can do that by editing the source file and typing in the test name in the core.run call.  However, I can't help by think a better UI is needed for doing this form for TestDriven Development. 
Basically, what I think would be perfect, is to have the UI, not run the tests initially.  It should provide you with a list of tests with checkboxes.  Then give you the opportunity to select which ones you want to run, and then run them.  It should also have the ability to re-run a test.  I realize that for any code changes to take affect you would need to re-run the entire app, but a lot of times, I find myself running the same test over and over and stepping through the code with the debugger in order to figure out what's going on.  Then I eventually change the code.
Also, the new UI should persist the last set of selected tests, and maybe have a way to store previous selections.  That would make it perfect for how I use it. 
Does anyone agree or disagree with this?  Has someone done this already?
BTW, the reason I'm using the stand alone runner and not the one in Flash Builder 4 is because I've run into some bugs with the FlexUnit shipped with Flash Builder 4 and there doesn't seem to be a way to get the latest FlexUnit 4.1 to work properly with Flash Builder 4.  There seems to be a way to do it with Flash Builder 4.5, but I don't have that version.
Thanks,
Mark

On 05/08/2012 03:56 PM, prakash jv wrote:
> We have been looking for unit test framework for unit testing SWT
> components in our RCP application developed in eclipse galileo 3.5.
>
> We found SWTBot supports the better UI testing and wanted to additional
> details reagrding its support for maven 2.2.1.
>
> Does SWTBot work with projects which are mavenized with maven 2.2.1?
>
> Our aim of adding the unit tests for UI components is for better build
> quality. So we would want these Unit tests to be run everytime we build
> our assembly. As of now we use Junit4 for running our JUnits and they
> run with maven outside eclipse.
>
> Does SWTBot support running the UI unit tests outside eclipse using maven?
Hi
in
http://code.google.com/a/eclipselabs.org/p/emf-components/
we run swtbot tests with maven/tycho
hope this helps
cheers
Lorenzo
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
ICQ# lbetto, 16080134 (GNU/Linux User # 158233)
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
http://www.myspace.com/supertrouperabba
BLOGS: http://tronprog.blogspot.com http://longlivemusic.blogspot.com
http://www.gnu.org/software/src-highlite
http://www.gnu.org/software/gengetopt
http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net

Similar Messages

  • Support for unit testing object types

    There's a Feature Request that suggests expanding the unit test tool to object types:
    Title
    Provide object type support for unit tests
    Description
    In the current version (2.1.0.63) I can perform only unit test for packages, function and procedures. But we use a lot of object types in the database and would like to test them. When is a support for object types scheduled?
    Average Rating
    10
    Development Comment
    This is planned for the next release.
    Status
    Scheduled for 3.0
    Although the status suggests inclusion in v3, in my current version 3.2.20.09 there is nothing.
    This is clearly an important issue for those who have voted for it as it scores a perfect 10 on average rating.
    Is there any sign of object types being supported in the 4.0EA1 release? There is a strong desire within my organisation to move to a more object-based approach to PL/SQL coding but until we are able to unit test easily there will be no real progress.

    If you are ready to learn a little bit of Ruby then you can try [PL/SQL unit testing with Ruby|http://blog.rayapps.com/2009/11/27/oracle-plsql-unit-testing-with-ruby/]. ruby-plsql library [supports also PL/SQL object types|http://blog.rayapps.com/2009/11/25/more-oracle-data-types-supported-by-ruby-plsql-gem/] as input and output parameters and return values.

  • [svn:osmf:] 15001: Implement a better http streaming unit testing structure .

    Revision: 15001
    Revision: 15001
    Author:   [email protected]
    Date:     2010-03-24 15:14:02 -0700 (Wed, 24 Mar 2010)
    Log Message:
    Implement a better http streaming unit testing structure.
    Modified Paths:
        osmf/trunk/framework/OSMFTest/org/osmf/net/httpstreaming/HTTPStreamingTestsHelper.as
        osmf/trunk/framework/OSMFTest/org/osmf/net/httpstreaming/f4f/TestAdobeBootstrapBox.as
    Added Paths:
        osmf/trunk/framework/OSMFTest/org/osmf/net/httpstreaming/AdobeBootstrapBoxDescriptor.as
        osmf/trunk/framework/OSMFTest/org/osmf/net/httpstreaming/AdobeFragmentRunTableDescriptor. as
        osmf/trunk/framework/OSMFTest/org/osmf/net/httpstreaming/AdobeSegmentRunTableDescriptor.a s
        osmf/trunk/framework/OSMFTest/org/osmf/net/httpstreaming/FragmentRunTableEntryDescriptor. as
        osmf/trunk/framework/OSMFTest/org/osmf/net/httpstreaming/SegmentRunTableEntryDescriptor.a s

    Revision: 15001
    Revision: 15001
    Author:   [email protected]
    Date:     2010-03-24 15:14:02 -0700 (Wed, 24 Mar 2010)
    Log Message:
    Implement a better http streaming unit testing structure.
    Modified Paths:
        osmf/trunk/framework/OSMFTest/org/osmf/net/httpstreaming/HTTPStreamingTestsHelper.as
        osmf/trunk/framework/OSMFTest/org/osmf/net/httpstreaming/f4f/TestAdobeBootstrapBox.as
    Added Paths:
        osmf/trunk/framework/OSMFTest/org/osmf/net/httpstreaming/AdobeBootstrapBoxDescriptor.as
        osmf/trunk/framework/OSMFTest/org/osmf/net/httpstreaming/AdobeFragmentRunTableDescriptor. as
        osmf/trunk/framework/OSMFTest/org/osmf/net/httpstreaming/AdobeSegmentRunTableDescriptor.a s
        osmf/trunk/framework/OSMFTest/org/osmf/net/httpstreaming/FragmentRunTableEntryDescriptor. as
        osmf/trunk/framework/OSMFTest/org/osmf/net/httpstreaming/SegmentRunTableEntryDescriptor.a s

  • Error while TOC created when change document  approvle for UNIT testing

    Hi All,
    During change document approval for unit testing, we are getting error, when I checked in detail, it is giving error for transport of copies error as below
    it seems to be getting locked with original transport,
    also I can't see change in transport of copies
    Does someone has any idea?
    Dinesh

    Hello Dinesh,
    Perhaps the tasks of the Transport Request were not released.
    Try to release the tasks only (from your DEV system), then choose action "Pass normal change to test". This will generate a ToC to be transported into your QAS.
    Then from the Task List, you can schedule the background job to import the ToC into QAS system.
    Regards,
    Daniel

  • [svn:osmf:] 15899: Attempted fix for unit tests failure.

    Revision: 15899
    Revision: 15899
    Author:   [email protected]
    Date:     2010-05-04 17:21:06 -0700 (Tue, 04 May 2010)
    Log Message:
    Attempted fix for unit tests failure.
    Modified Paths:
        osmf/trunk/framework/OSMFTest/org/osmf/OSMFTests.as

  • Roles for unit test

    Hi all,
    I need to create users and assign role for unit test client. But I do not known which roles  I have to assign to them. If you know, pls tell me.
    Thanks alot.

    Hello,
    it depends on what they want to test. You cannot give SAPALL for them.
    Create users in SU01
    Create roles in PFCG
    Mass change users in SU10
    Regards,
    Ravi

  • Tool for Unit Testing

    Hi,
    Is there any tool for unit testing.
    Thanks
    krish

    Hi Krish,
    Check the below help file for testing.
    http://help.sap.com/saphelp_nw04/helpdata/en/1b/e81c3b84e65e7be10000000a11402f/frameset.htm
    Hope it helps.
    Regards,
    Raghu

  • Suggestions requested for Unit Testing process and build processes.

    Hi All,
    We are using WebLogic WorkShop 8.1 SP2 to build our WebApp. One thing I am trying
    to get together is a "Best Practises" list for aspects of WorkShop developement,
    particularly Unit Testing, Continous Build methodology, source control management
    etc.I have been through the "Best Practises Guide" that comes in WorkShop help,
    but it doesnt address these issues.This could help us all for future projects.
    1)Could anyone give pointers on how to perform Unit Testing using either JUnit/JUnitEE
    in the WorkShop realm, given that Controls cannot be accessed directly from PO
    Test classes.
    2)For a project of size say 5 developers ,does it make sense to have a nightly
    build using tools like CruiseControl?We use CVS for our source control and its
    working out pretty well, but given that we currently have no Unit Tests that can
    be run after the build and that can provide some reports on what broke/what didnt?
    I am sure we all would appreciate any suggestions and more questions on this topic.
    Thanks,
    Vik.

    Hi, Chris,
    can you perhaps explain your solution in greater detail. I am really curious to
    find a way to test controls.
    "Chris Pyrke" <[email protected]> wrote:
    >
    I have written (well it's a bit of a dirty hack really) something that
    lends itself
    to the name ControlTest (it unit tests controls). Its a blend of Junit
    and Cactus
    with some of the source of each brutalised a bit to get things to work
    (not much
    - it was a couple of hours work, when I was supposed to be doing something
    else).
    To write a control test you code something like...
    package com.liffe;
    import com.liffe.controlunit.ControlTestCase;
    import controls.Example;
    public class TestExample extends ControlTestCase
    private Example example = null;
    public void setUp() {
    example = (Example)getControl("example");
    public void testExample() {
    this.assertNotNull(example);
    String result = example.getData();
    assertEquals(result, "Happy as Larry");
    Other tasks required to set up a test are creating a web project with
    a jpf which
    needs some cut and paste code (14 lines) in its begin method and a jsp
    which is
    also cut and paste (5 lines). (ie create a standard web project and paste
    in 2
    pieces of code)
    In the web project you need to create a control (A) with an instance
    name of controlContainer.
    (if it's called something else the pasted in code will need changing
    to reflect)
    In this control you need to put an instance of TestContainerImpl and
    any controls
    that need testing.
    You then need to add a method to the control (A) that looks like…
    * @common:operation
    public String controlTestRun(String theSuiteClassName, boolean xsl)
    container.setControl("example", example);
    return container.controlTestRun(theSuiteClassName, xsl);
    You need to call container.setControl for each control being tested and
    the object
    'container' is the instance name of the TestContainerImpl that was put
    in.
    There are 4 jars (junit, cactus etc) that go in the library. You will
    also need
    the ControlUnitBase project (or maybe just it's jar).
    To use you call a URL like:
    http://localhost:7001/TestWeb/Controller.jpf?test=com.liffe.TestExample
    TestWeb is the name I gave to my web project - this will be different
    for each
    test project
    com.liffe.Example is the class above and will therefore be different
    for each
    test case.
    You can also call
    http://localhost:7001/TestWeb/Controller.jpf?test=com.liffe.TestExample&xsl=true
    (Note the extra &xsl=true) and the browser will (if it can) render it
    more prettily.
    This seems to do the job quite nicely, but there are several caveats
    I would hope
    someone from bea would be able to address before I start using it widely.
    1) To access the control you need to create it (eg as a subcontrol in
    the control
    (A) above.
    To get it into the test case you need to pass it round as an Object (can't
    return
    Control from a control operation). As it's being passed around among
    Java (POJO)
    classes I'm assuming that control remains in the control container context
    so
    this is OK. It seems to work and the Object is some form of proxy as
    any control
    seems to be reproxied before the control is invoked from the test case.
    2) If I'm testing controls called from a JPD then they either need to
    be in a
    control project (and my test cases called from a Web Project) which makes
    for
    a large increase in project numbers (we already have this and are trying
    to resist
    it) To avoid this - as a process project is a brain damaged web project
    I simply
    perform some brain surgery and augment the process project with some
    standard
    files found in any old web project. this means I can call the test JPF
    from a
    browser. This seems nasty, is there a better way?
    3) I would like to be able to deliver without the test code. At the worst
    the
    code can be in place but must be inacessible in a production environment.
    I don't
    know how best to do this - any suggestions (without creating lots of
    projects,
    or lots of manual effort)
    If anyone has read this far I would ask the question does this seem like
    the kind
    of thing that would be useful?
    Hopefully a future version of workshop will have something to enable
    unit testing
    and this hacking will be unnecessary.
    Could someone from BEA tell me if this is a dangerous way to do things?
    Chris
    "vik" <[email protected]> wrote:
    Hi All,
    We are using WebLogic WorkShop 8.1 SP2 to build our WebApp. One thing
    I am trying
    to get together is a "Best Practises" list for aspects of WorkShop developement,
    particularly Unit Testing, Continous Build methodology, source control
    management
    etc.I have been through the "Best Practises Guide" that comes in WorkShop
    help,
    but it doesnt address these issues.This could help us all for future
    projects.
    1)Could anyone give pointers on how to perform Unit Testing using either
    JUnit/JUnitEE
    in the WorkShop realm, given that Controls cannot be accessed directly
    from PO
    Test classes.
    2)For a project of size say 5 developers ,does it make sense to have
    a nightly
    build using tools like CruiseControl?We use CVS for our source control
    and its
    working out pretty well, but given that we currently have no Unit Tests
    that can
    be run after the build and that can provide some reports on what broke/what
    didnt?
    I am sure we all would appreciate any suggestions and more questions
    on this topic.
    Thanks,
    Vik.

  • Possible to have multiple cluster members in the same JVM (for unit tests)?

    Hi,
    I'm wondering if it's possible to simulate multiple cluster members inside of a single JVM. I'm looking to unit test my code and it would be great to write cases for various boundary conditions.
    This could certainly be done with multiple JVMs but would be more difficult to run in something like cruise control etc.
    TIA,
    Danny

    Hi Danny,
    I do not know how to accomplish what you are asking for and run several Coherence nodes in a single JVM, but I have written a JUnit base class that starts a configurable number of nodes (each in its own JVM) and provides some other useful methods for unit/integration testing with Coherence, such as method to clear all caches or to load test data from the CSV file.
    It is still a work in progress and you might need to tweak things a bit to make it work in your environment, but it will at least give you a head start.
    Shoot me an email if you are interested and I'll send it to you (you can find my email in my profile).
    Regards,
    Aleks

  • 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.

  • Required Unit test Plan for Data migration

    Dear All,
    I am looking for unit test plan Draft documents/templates which covers
    1. Testing tools
    2. Methods
    3. Error handling
    4. Reviews and approvals
    The project is a Oracle 10g data migration from one schema to another schema.
    It will be a greate help if anyone can forward the same to me.
    Thank you.

    Hi Vaishali,
    You may wish to refer the links below...
    https://service.sap.com/instguides --> SAP NetWeaver --> Release 2004s --> Upgrade
    https://www.sdn.sap.com/irj/sdn/developerareas/bi
    latest on upgrade tp BI7.0
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/2e8e5288-0b01-0010-2ea8-bcd4df5084a7
    Upgrading BW 3.X to SAP NetWeaver 2004s BI (PDF 2.6 MB)
    Front End Migration strategy
    Here's the migration strategy: Rolling out the New SAP NetWeaver 2004s BI Frontend Tools
    Presentation
    http://csc-studentweb.lrc.edu/swp/Berg/Articles/PM_2006_upgrade_NW2004s_Bjarne_Berg_v12.ppt
    Here are the frontend requirements:
    Troubleshoot the SAP NetWeaver 2004s BI Frontend Installation
    Here are the backend requirements in the product availabilty matrix:
    https://websmp110.sap-ag.de/~form/handler?_APP=00200682500000001303&_EVENT=DISP_NEW&00200682500000002804=01200615320900001250
    Migration of Web Teplates
    832713 - Migration of Web templates from BW 3.x to Netweaver
    Assign points if this helps.
    Regards,
    Anil

  • BeginTimer and EndTimer Not Working In Data-Driven Unit Test Using DataSource Attribute

    Using VS2012 Ultimate I have a unit test with the <DataSource> attribute which passes in values from a CSV file.  I'm wrapping the unit test in a load test.  I expect a Transaction to appear in the load test results for each row in my DataSource
    due to the BeginTimer and EndTimer methods in the unit test.  However, I only get 1 transaction, with response time roughly equal to the overall test time.  For example, if each row in the DataSource takes 1 second to process, then my test time and
    transaction time would be about 10 seconds with 10 rows in the CSV file.
    I've created a load test with Constant Load Pattern, 1 user, and 1 test iteration.  Seeing the behavior described above.
    I have tried with and without and the check for $LoadTestUserContext.  I'm only using that because I get a NotSupportedException when running the unit test on its own.  I can't believe this bug still
    exists, but that is another topic.
    Note also that I cannot see the Debug output in the Output window in VS2012.
    Any tips?  Thank you.
        <TestMethod()>
        <DataSource("Microsoft.VisualStudio.TestTools.DataSource.CSV", "|DataDirectory|\TestData\MyValues.csv", "MyValues#csv", DataAccessMethod.Sequential)>
        Public Sub WebServiceTest()
            Dim service As MySvc = New MySvcClient()
            Dim input As MyInput = New MySvcInput()
            input.A = testContextInstance.DataRow("A")
            input.B = testContextInstance.DataRow("B")
            Dim g As Guid = Guid.NewGuid()
            If TestContext.Properties.Contains("$LoadTestUserContext") Then 'running as load test
                TestContext.BeginTimer("MySvcTrans")
                Debug.WriteLine("Begin Transaction MySvcTrans:  {0}", g)
            End If
            Dim output As MySvcOutput = service.Method(input)
            If TestContext.Properties.Contains("$LoadTestUserContext") Then 'running as load test
                Debug.WriteLine("End Transaction MySvcTrans:  {0}", g)
                TestContext.EndTimer("MySvcTrans")
            End If
            Assert.AreEqual(0, output.ReturnCode)
        End Sub

    Hi John,
    >> I expect a Transaction to appear in the load test results for each row in my DataSource due to the BeginTimer and EndTimer methods in the unit test.  However, I only get 1 transaction, with response time roughly equal to the overall test
    time.
    Could you share me a screen shot about the reslut in load test?
    Could you share us the load test result in "Transaction"Tables?
    About how to use the
    Transaction for unit tests, maybe you could get useful informaiton here:
    http://blogs.msdn.com/b/slumley/archive/2006/04/14/load-testing-web-services-with-unit-tests.aspx
    Best Regards,
    Jack
    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.

  • Trouble w unit test code

    this code compiles fine, but my unit tests starting with the lines
    public static class AllTests extends TestCase {
    are failing with a null pointer exception. i was advised that
    '>
    The testCreateAccount is failing because you're using a local variable,newAccount,
    in the setUp method(), which has the same name as the class instance variable,newAccount.
    Since the testCreateAccount uses the class instance variable, it is null.
    protected void setUp() {
    anAccountServiceImpl = new AccountServiceImpl();
    AccountEntryStruct newAccount = new AccountEntryStruct();'-so i changed all instances of newAccount to newAccount2 in my unit tests (you
    will see towards
    the bottom of my code). it looks like the testCreateAccount method is still
    using a
    null value. i'm not sure if i'm following the advice correctly...
    code is below:
    // AccountServiceImpl.java: The AccountService Implementation
    package com.kafein.accountServices;
    import java.util.Hashtable;
    import java.util.Calendar;
    import java.util.GregorianCalendar;
    import junit.framework.TestCase;
    import junit.framework.Test;
    import junit.framework.TestSuite;
    import org.omg.PortableServer.*;
    import com.kafein.idl.accountServices.AccountServicePOA;
    import com.kafein.idl.accountServices.AccountEntryStruct;
    import com.kafein.idl.accountServices.AccountStruct;
    import com.kafein.idl.utilities.DateTimeStruct;
    import com.kafein.idl.exceptions.NotFoundException;
    import com.kafein.idl.exceptions.DataValidationException;
    import com.kafein.idl.errorCodes.DataValidationErrorCodes;
    import com.kafein.utils.ServiceHandler;
    import com.kafein.utils.Log;
    public class AccountServiceImpl extends AccountServicePOA {
    POA poa;
    private Hashtable accounts = new Hashtable(); // collection of Accounts
    private static int nextAccountID = 1; // global account ID
    * Construct an instance.
    public AccountServiceImpl(POA aPOA) {
    super();
    poa = aPOA;
    * Overloaded constructor for unit tests.
    protected AccountServiceImpl() {
    poa = null;
    * createAccount is used by administrator to add a new Account
    * in the system.
    * @param newAccount AccountEntryStruct containing data for new account
    * @return int the new unique Account ID
    * @exception com.kafein.idl.exceptions.DataValidationException
    public int createAccount(AccountEntryStruct newAccount) throws
    DataValidationException {
    validateData (newAccount); // throws DataValidationException;
    int accountID = getNextID();
    // Create new Account.
    Account anAccount = new Account(accountID,
    newAccount.userName,
    newAccount.userEmail,
    newAccount.creditCardType,
    newAccount.creditCardNumber,
    newAccount.creditCardExpirationDate.year,
    newAccount.creditCardExpirationDate.month,
    newAccount.userPassword,
    newAccount.initialBalance);
    accounts.put(accountID,anAccount);
    return accountID;
    * isAccountValid is used to validate a user logon.
    * @param accountID AccountID
    * @param userPassword String
    * @return boolean true to indicate an existing Account
    public boolean isValidAccount (int accountID, String userPassword) {
    // Get account with key equal to accountID.
    AccountStruct anAccount;
    try {
    anAccount = (AccountStruct) getAccount (accountID);
    catch (NotFoundException e) {
    return false;
    // Verify password.
    return (anAccount.userPassword.equals(userPassword) ? true : false);
    * getAccount is used to retrieve an existing Account in the system
    * @param int AccountID
    * @return AccountStruct containing data for the existing Account
    * @exception com.kafein.idl.exceptions.NotFoundException
    public AccountStruct getAccount(int accountID)throws
    NotFoundException {
    // Verify that accountID is within an appropriate interval.
    if (accountID < 1 || accountID > accounts.size()) {
    throw new NotFoundException(DataValidationErrorCodes.INVALID_ACCOUNT_ID,
    "Account ID not found");
    // Get Account and convert to AccountStruct (which is returned).
    Account anAccount = (Account) accounts.get(accountID);
    return anAccount.getAccountStruct();
    * getAllAccounts is used to retrieve all existing Accounts in the system
    * @return AccountStruct[] containing all existing Accounts.
    * @fyi returns an empty sequence if no Accounts exist
    public AccountStruct[] getAllAccounts() {
    // Allocate the array of AccountStructs.
    int lastKey = accounts.size();
    AccountStruct[] accountSequence = new AccountStruct[lastKey];
    if (lastKey==0) {
    return accountSequence;
    // DAR:Sort accounts by accountID (int).
    // Create AccountStructs from Accounts.
    for (int i = 1; i <= lastKey; i++) {
    Account anAccount = (Account) accounts.get(i);
    accountSequence[i-1] = anAccount.getAccountStruct();
    return accountSequence;
    * validateData is used to check new account data.
    * @param newAccount AccountEntryStruct containing data for new account
    * @exception com.kafein.idl.exceptions.DataValidationException
    protected void validateData(AccountEntryStruct newAccount) throws
    DataValidationException {
    // Check all of the member data in newAccount.
    if (newAccount.userName.equals("")) {
    throw new DataValidationException(
    DataValidationErrorCodes.INVALID_USER_NAME,
    "User Name must not be empty");
    if (newAccount.userEmail.equals("")) {
    throw new DataValidationException(
    DataValidationErrorCodes.INVALID_USER_EMAIL,
    "User Email must not be empty");
    if (newAccount.creditCardType.equals("")) {
    throw new DataValidationException(
    DataValidationErrorCodes.INVALID_CREDIT_CARD_TYPE,
    "Credit card type must not be empty");
    if (newAccount.creditCardNumber.equals("")) {
    throw new DataValidationException(
    DataValidationErrorCodes.INVALID_CREDIT_CARD_NUMBER,
    "Credit card number must not be empty");
    // Compare creditCardExpirationDate to current date
    // (we only consider year and month).
    GregorianCalendar now = new GregorianCalendar();
    DateTimeStruct proposed = newAccount.creditCardExpirationDate;
    if (proposed.year < now.get (Calendar.YEAR) ||
    (proposed.year == now.get (Calendar.YEAR) &&
    proposed.month < now.get (Calendar.MONTH) + 1)) {
    throw new DataValidationException(
    DataValidationErrorCodes.INVALID_CREDIT_CARD_EXPIRATION_DATE,
    "Credit card has expired");
    if (newAccount.userPassword.equals("")) {
    throw new DataValidationException(
    DataValidationErrorCodes.INVALID_USER_PASSWORD,
    "Password must not be empty");
    else if
    (!newAccount.userPassword.equals(newAccount.userPasswordVerification)) {
    throw new DataValidationException(
    DataValidationErrorCodes.INVALID_USER_PASSWORD,
    "Password verification failure");
    if (newAccount.initialBalance < 0.0F) {
    throw new DataValidationException(
    DataValidationErrorCodes.INVALID_BALANCE,
    "Account Balance cannot have a negative balance");
    * getNextID is used to generate a unique ID.
    * Needs a much better implementation that generates a globally unique ID!
    * @return int an Account ID
    protected synchronized int getNextID() {
    nextAccountID++;
    return nextAccountID - 1;
    * override defaultPOA to return this servant's POA, not Root POA
    public POA defaultPOA() {
    return poa;
    * AllTests is used for unit testing the AccountServiceImpl Class. It
    extends the
    * JUnit testing framework's TestCase class.
    * To execute in graphic mode:
    * java junit.swingui.TestRunner
    com.kafein.accountServices.AccountServiceImpl$AllTests
    * To execute in text mode:
    * java com.kafein.accountServices.AccountServiceImpl$AllTests
    public static class AllTests extends TestCase {
    private AccountServiceImpl anAccountServiceImpl;
    private Hashtable accounts = new Hashtable();
    private Account anAccount;
    private AccountEntryStruct newAccount2;
    public AllTests(String name) {
    super(name);
    protected void setUp() {
    anAccountServiceImpl = new AccountServiceImpl();
    AccountEntryStruct newAccount2 = new AccountEntryStruct();
    newAccount2.userName = "testName";
    newAccount2.userEmail = "test@email";
    newAccount2.creditCardType = "testCreditCardType";
    newAccount2.creditCardNumber = "0123456789";
    newAccount2.creditCardExpirationDate = new DateTimeStruct();
    newAccount2.creditCardExpirationDate.year = 2005;
    newAccount2.creditCardExpirationDate.month = 6;
    newAccount2.creditCardExpirationDate.day = -1; // not applicable data
    newAccount2.creditCardExpirationDate.hour = -1;
    newAccount2.creditCardExpirationDate.minute = -1;
    newAccount2.userPassword = "kafein";
    newAccount2.userPasswordVerification = "kafein";
    newAccount2.initialBalance = 0.0F;
    protected void tearDown() {
    public static void main (String[] args) {
    junit.textui.TestRunner.run(suite());
    public static Test suite() {
    return new TestSuite(AllTests.class);
    public void testGetAllAccountsSizeZero() {
    AccountStruct[] results =
    anAccountServiceImpl.getAllAccounts();
    assertTrue(results != null);
    assertTrue(results.length == 0);
    public void testCreateAccount() {
    try {
    int testAccountID = anAccountServiceImpl.createAccount(newAccount2);
    //fail(); // shouldn't get here
    assertTrue(testAccountID == 1);
    AccountStruct[] results = anAccountServiceImpl.getAllAccounts();
    assertTrue(results[0].userName.equals("testName"));
    assertTrue(anAccountServiceImpl.isValidAccount(1, "kafein"));
    } catch(DataValidationException e) {
    public void testGetAllAccounts() {
    AccountStruct[] results = anAccountServiceImpl.getAllAccounts();
    assertTrue(results[0].userName.equals("testName"));
    public void testIsValidAccount() {
    assertTrue(anAccountServiceImpl.isValidAccount(1, "kafein"));
    }

    thanks again all
    my code now looks like
            public static class AllTests extends TestCase {
              private AccountServiceImpl anAccountServiceImpl;
              private Hashtable accounts = new Hashtable();
              private Account anAccount;
              private AccountEntryStruct newAccount2;
              public AllTests(String name) {
                            super(name);
                    protected void setUp() {
              anAccountServiceImpl = new AccountServiceImpl();
              newAccount2 = new AccountEntryStruct();
              newAccount2.userName = "testName";
                    newAccount2.userEmail = "test@email";
                    newAccount2.creditCardType = "testCreditCardType";
                   newAccount2.creditCardNumber = "0123456789";
                    newAccount2.creditCardExpirationDate = new DateTimeStruct();
                    newAccount2.creditCardExpirationDate.year = 2005;
                    newAccount2.creditCardExpirationDate.month = 6;
                    newAccount2.creditCardExpirationDate.day = -1; // not applicable data
                    newAccount2.creditCardExpirationDate.hour = -1;
                    newAccount2.creditCardExpirationDate.minute = -1;
                    newAccount2.userPassword = "kafein";
                    newAccount2.userPasswordVerification = "kafein";
                    newAccount2.initialBalance = 0.0F;
                    protected void tearDown() {
                    public static void main (String[] args) {
                            junit.textui.TestRunner.run(suite());
                    public static Test suite() {
                            return new TestSuite(AllTests.class);
              public void testGetAllAccountsSizeZero() {
                        AccountStruct[] results = anAccountServiceImpl.getAllAccounts();
                        assertTrue(results != null);
                        assertTrue(results.length == 0);
                    public void testCreateAccount() {
                    try {
              int testAccountID = anAccountServiceImpl.createAccount(newAccount2);
              assertTrue(testAccountID == 1);
              AccountStruct[] results = anAccountServiceImpl.getAllAccounts();
              assertTrue(results[0].userName.equals("testName"));
              assertTrue(anAccountServiceImpl.isValidAccount(1, "kafein"));
                      //fail(); // shouldn't get here
              } catch(DataValidationException e) {
                    public void testGetAllAccounts() {
              AccountStruct[] results = anAccountServiceImpl.getAllAccounts();
              assertTrue(results[0].userName.equals("testName"));
                    public void testIsValidAccount() {
              assertTrue(anAccountServiceImpl.isValidAccount(1, "kafein"));
    }-it compiles cleanly. unit tests testGetAllAccounts() and testIsValidAccount() are failing still, however. i'm not sure how to initialize the struct outside of the setUp method and have the struct be available to methods outside of setUp()

  • No ConfigurationManager object available in unit test.

    VS2013
    I have a unit test in which I try to add:
    using System.Configuration;
    And ConfigurationManager.AppSettings or ConfigurationManager.ConnectionStrings
    And those are not available?
    Why and how can I read the App config during testing? Thank you.

    Hi chrislynn,
    I doubt that the way you used is for Nunit framework.
    Reference:
    http://www.codeproject.com/Tips/208979/Changing-App-Config-on-the-fly-for-unit-testing
    In VS IDE, maybe this way is what you want to get when you want to use a config file as a data source.https://msdn.microsoft.com/en-us/library/ms243192(v=vs.120).aspx
    Best Regards,
    Jack
    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.

  • Unit testing and Issue on ODS

    Hi every one,
    I was asked to do Unit testing on all the objects I created which includes data loading, checking the structure.....etc...If any one has any template for Unit testing pls forward it to me [email protected].....
    My ods is designed with out checking "Activate ODS data immeaditely".....and we r not using process chains here...
    while testing data loads when ever we send data data to that ODS how do u activate it thru jobs automatically????
    if we give Job selection it may not work out right, cos we don't know when we load data....so can I make use of events so that when ever data comes to ODS I need to activate it and it has to push that data to other ODS...can anyone throw some light on the events and what even to use for automatic activation....
    If any one has any template pls forward it to the above ID
    Thanks in advance

    BW
    Doing unit test is simple. Just document what ever the steps you follow while loading your ODS. You could follow these steps
    1 . Check the functionality of your Infosource whether it is full or Delta – Take a screen shot.
    2.   Check Delta Load Functionality if you have any Delta extractors.
    4     . Schedule the Info Package
    5     Go to Manage Data targets and see whether ODS got loaded successfully or not.
    6     Check if it is activated or Not. In your case it will automatically gets activated since you selected automatic activation.
    Don’t forget to take screen shots of each Process
    Hope this helps
    Thanks
    Sat

Maybe you are looking for

  • Server hangs and session variable value not maintained.

    dear all, this is exteremetly urgent. i upgraded my tomcat to 4.1.24.but i have problems running the same code which was working earlier, i get null in the value of session variable. and also get the following error ////////////////error got ////////

  • Automatich download JRE

    Hi, In the jnlp file it's possible to specifiy the jre version needed to run the application. Example : <j2se version="1.4+"/> Because I'm not sure that the JRE 1.4 is installed on the client machine and because the automatic download from the Sun si

  • Download internal table to presentation server in UTF-8 format

    Hello everyone. We are trying to use function module GUI_DOWNLOAD to download data from internal table to a text file (filetype ASCII). The defualt encoding for the text file is ANSI but we need to download it with the encoding UTF-8. We have already

  • Third party Wireless Card on a Power Mac G5, bipro 1.8 GHz

    Does anyone has a definite answer whether or not a TrendNet 403 PI+ PCI card would work or not along with my G5 bipro 1.8 Ghz (beginning 05- OS 10.3.9) ? I have the same card installed on my B&W, which is recognized as an airport extreme card. Instal

  • Iphone 4 and ipod classic computer autorisation bug

    Hi there, I'm having some problems with both my ipod and iphone. I use my iphone on my PC and my Mac so 2 machine only it has not been connected anywhere else, however it tells me that I have it authorised on 4 machines and so i have only 1 authorisa